Make pattern compilation local to function
authorChristian Ebert <blacktrash@gmx.net>
Thu, 14 Dec 2006 08:17:01 +0100
changeset 3 b9f2c0853da3
parent 2 0bda12ebde94
child 4 7e618d820490
child 5 85d1f5bf7cfc
child 193 7a775a8f6fb9
Make pattern compilation local to function
hgkw/hgkwencode.py
--- a/hgkw/hgkwencode.py	Tue Dec 12 23:35:45 2006 +0100
+++ b/hgkw/hgkwencode.py	Thu Dec 14 08:17:01 2006 +0100
@@ -2,9 +2,8 @@
 
 import re, sys
 
-#re_kw = re.compile(r'[$]Hg.*?[$]')
-re_kw = re.compile(r'([$]Hg: .+?,v) [a-z0-9]{12} [^$]+? [$]')
+def kwencode():
+    '''Truncates keywords in IO stream.'''
 
-def kwencode():
-    sys.stdout.write(
-            re_kw.sub(r'\1$', sys.stdin.read()))
+    re_kwtrunc = re.compile(r'([$]Hg: .+?,v) [a-z0-9]{12} [^$]+? \$')
+    sys.stdout.write(re_kwtrunc.sub(r'\1$', sys.stdin.read()))