contrib/check-code.py
changeset 10727 62b8f15683f2
parent 10723 8ea152e94484
child 10814 cd0c49bdbfd9
--- a/contrib/check-code.py	Thu Mar 18 01:59:53 2010 +0100
+++ b/contrib/check-code.py	Thu Mar 18 16:32:03 2010 +0100
@@ -14,6 +14,12 @@
     t = re.sub(r"[^\sx]", "o", t)
     return m.group('quote') + t + m.group('quote')
 
+def reppython(m):
+    comment = m.group('comment')
+    if comment:
+        return "#" * len(comment)
+    return repquote(m)
+
 def repcomment(m):
     return m.group(1) + "#" * len(m.group(2))
 
@@ -96,10 +102,10 @@
 ]
 
 pyfilters = [
-    (r"""(?msx)(?P<quote>('''|\"\"\"|(?<!')'(?!')|(?<!")"(?!")))
-         (?P<text>(.*?))
-         (?<!\\)(?P=quote)""", repquote),
-    (r"( *)(#([^\n]*\S)?)", repcomment),
+    (r"""(?msx)(?P<comment>\#.*?$)|
+         ((?P<quote>('''|\"\"\"|(?<!')'(?!')|(?<!")"(?!")))
+          (?P<text>(([^\\]|\\.)*?))
+          (?P=quote))""", reppython),
 ]
 
 cpats = [