contrib/check-code.py
changeset 20012 a1d88278beff
parent 19983 e1317d3e59e1
parent 20005 22154ec6fb8b
child 20013 38acecdd016c
--- a/contrib/check-code.py	Fri Nov 15 13:20:49 2013 -0800
+++ b/contrib/check-code.py	Sat Nov 16 12:44:28 2013 -0500
@@ -26,8 +26,25 @@
     return re.compile(pat)
 
 def repquote(m):
-    t = re.sub(r"\w", "x", m.group('text'))
-    t = re.sub(r"[^\s\nx]", "o", t)
+    fromc = '.:'
+    tochr = 'pq'
+    def encodechr(i):
+        if i > 255:
+            return 'u'
+        c = chr(i)
+        if c in ' \n':
+            return c
+        if c.isalpha():
+            return 'x'
+        if c.isdigit():
+            return 'n'
+        try:
+            return tochr[fromc.find(c)]
+        except (ValueError, IndexError):
+            return 'o'
+    t = m.group('text')
+    tt = ''.join(encodechr(i) for i in xrange(256))
+    t = t.translate(tt)
     return m.group('quote') + t + m.group('quote')
 
 def reppython(m):
@@ -263,6 +280,7 @@
   ],
   # warnings
   [
+    (r'(^| )pp +xxxxqq[ \n][^\n]', "add two newlines after '.. note::'"),
   ]
 ]
 
@@ -449,6 +467,8 @@
             else:
                 p, msg = pat
                 ignore = None
+            if i >= nerrs:
+                msg = "warning: " + msg
 
             pos = 0
             n = 0
@@ -456,8 +476,6 @@
                 if prelines is None:
                     prelines = pre.splitlines()
                     postlines = post.splitlines(True)
-                    if i >= nerrs:
-                        msg = "warning: " + msg
 
                 start = m.start()
                 while n < len(postlines):
@@ -484,6 +502,7 @@
                         bl, bu, br = blamecache[n]
                         if bl == l:
                             bd = '%s@%s' % (bu, br)
+
                 errors.append((f, lineno and n + 1, l, msg, bd))
                 result = False