changeset 19999:169cb9e47f8e stable

check-code: more replacement characters for finding '.. note::' (even) more exact by using more characters: replace '.' with 'p' and ':' with 'q'
author Simon Heimberg <simohe@besonet.ch>
date Tue, 05 Nov 2013 09:00:31 +0100
parents 289bbb294e82
children 0849d280663e
files contrib/check-code.py
diffstat 1 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/check-code.py	Tue Nov 05 09:00:31 2013 +0100
+++ b/contrib/check-code.py	Tue Nov 05 09:00:31 2013 +0100
@@ -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,7 +280,7 @@
   ],
   # warnings
   [
-    (r'(^| )oo +xxxxoo[ \n][^\n]', "add two newlines after '.. note::'"),
+    (r'(^| )pp +xxxxqq[ \n][^\n]', "add two newlines after '.. note::'"),
   ]
 ]