r15305 - meta/scripts - move the comment to a better place; add support for '#' and '~' in urls.

Joshua Sled jsled at cvs.gnucash.org
Tue Jan 2 22:10:47 EST 2007


Author: jsled
Date: 2007-01-02 22:10:46 -0500 (Tue, 02 Jan 2007)
New Revision: 15305
Trac: http://svn.gnucash.org/trac/changeset/15305

Modified:
   meta/scripts/irc_log_htmlizer.py
Log:
move the comment to a better place; add support for '#' and '~' in urls.


Modified: meta/scripts/irc_log_htmlizer.py
===================================================================
--- meta/scripts/irc_log_htmlizer.py	2007-01-03 00:12:19 UTC (rev 15304)
+++ meta/scripts/irc_log_htmlizer.py	2007-01-03 03:10:46 UTC (rev 15305)
@@ -9,15 +9,13 @@
 
 Run something like:
 
-    $ nohup tail -0 -f #gnucash.log | ~/scripts/irc_log_htmlizer.py &
+    $ nohup tail -n 0 -f #gnucash.log | ~/scripts/irc_log_htmlizer.py &
 
 Or, to catch up on a period of time:
 
     $ rm ~/public/logs/2007-01-*
     $ egrep "^2007-01-..T" | ~/scripts/irc_log_htmlizer.py
 
- at todo Supybot emits "[...]T11:53:16 <jsled> -= THIS MESSAGE NOT LOGGED =-" lines; remove these.
-
 @author jsled
 '''
 
@@ -46,9 +44,26 @@
     return date,time,rest
 
 
+# From http://www.ietf.org/rfc/rfc1738.txt:
+# genericurl     = scheme ":" schemepart
+# [...]
+# schemepart     = *xchar | ip-schemepart
+# safe           = "$" | "-" | "_" | "." | "+"
+# extra          = "!" | "*" | "'" | "(" | ")" | ","
+# reserved       = ";" | "/" | "?" | ":" | "@" | "&" | "="
+# unreserved     = alpha | digit | safe | extra
+# uchar          = unreserved | escape
+# xchar          = unreserved | reserved | escape
+# digits         = 1*digit
+#
 # Minimize the first group to work left-to-right...
-link_re = re.compile(r'''(^.*?)((https?|ftp|telnet|irc|mailto|file):([-a-zA-Z0-9$_.+!*'(),;/?:@&=]|%[0-9a-fA-F][0-9a-fA-F])+)(.*$)''')
+#
+# @@fixme This doesn't capture '#fragment_identifiers' on urls...
+# @@fixme Nor does it allow <http://host/~jsled>
+#
+link_re = re.compile(r'''(^.*?)((https?|ftp|telnet|irc|mailto|file):([-a-zA-Z0-9$_.+!*'(),;/?:@&=~#]|%[0-9a-fA-F][0-9a-fA-F])+)(.*$)''')
 # ' # emacs/font-lock balance
+
 def escape_and_linkify(s):
     '''
     Adds <a href>s around links in a string, and html-escapes the rest.
@@ -68,19 +83,11 @@
     >>> escape_and_linkify('<http://www.gnucash.org/?test=%2F> and <file:///usr/bin/gnucash>.')
     '&lt;<a href="http://www.gnucash.org/?test=%2F">http://www.gnucash.org/?test=%2F</a>&gt; and &lt;<a href="file:///usr/bin/gnucash">file:///usr/bin/gnucash</a>&gt;.'
 
+    >>> escape_and_linkify('http://cafe.berkeley.edu/~joshua#contact')
+    '<a href="http://cafe.berkeley.edu/~joshua#contact">http://cafe.berkeley.edu/~joshua#contact</a>'
+
     '''
     # ' # emacs/font-lock balance.
-    # From http://www.ietf.org/rfc/rfc1738.txt:
-    # genericurl     = scheme ":" schemepart
-    # [...]
-    # schemepart     = *xchar | ip-schemepart
-    # safe           = "$" | "-" | "_" | "." | "+"
-    # extra          = "!" | "*" | "'" | "(" | ")" | ","
-    # reserved       = ";" | "/" | "?" | ":" | "@" | "&" | "="
-    # unreserved     = alpha | digit | safe | extra
-    # uchar          = unreserved | escape
-    # xchar          = unreserved | reserved | escape
-    # digits         = 1*digit
     global link_re
     match = link_re.match(s)
     if not match:



More information about the gnucash-changes mailing list