changeset 19307:5443d40d524b

check-code: only fix patterns once The patterns were fixed once for every file. Now only do it once when loading the file.
author Simon Heimberg <simohe@besonet.ch>
date Sat, 08 Jun 2013 20:20:14 +0200
parents 59cdd3a7e281
children 84faaacbd3fa
files contrib/check-code.py
diffstat 1 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/check-code.py	Fri Jun 07 16:59:59 2013 -0500
+++ b/contrib/check-code.py	Sat Jun 08 20:20:14 2013 +0200
@@ -317,6 +317,22 @@
     ('txt', r'.*\.txt$', txtfilters, txtpats),
 ]
 
+def _preparepats():
+    for c in checks:
+        failandwarn = c[-1]
+        for pats in failandwarn:
+            for i, pseq in enumerate(pats):
+                # fix-up regexes for multi-line searches
+                po = p = pseq[0]
+                # \s doesn't match \n
+                p = re.sub(r'(?<!\\)\\s', r'[ \\t]', p)
+                # [^...] doesn't match newline
+                p = re.sub(r'(?<!\\)\[\^', r'[^\\n', p)
+
+                #print po, '=>', p
+                pats[i] = (p,) + pseq[1:]
+_preparepats()
+
 class norepeatlogger(object):
     def __init__(self):
         self._lastseen = None
@@ -403,15 +419,6 @@
                 p, msg = pat
                 ignore = None
 
-            # fix-up regexes for multi-line searches
-            po = p
-            # \s doesn't match \n
-            p = re.sub(r'(?<!\\)\\s', r'[ \\t]', p)
-            # [^...] doesn't match newline
-            p = re.sub(r'(?<!\\)\[\^', r'[^\\n', p)
-
-            #print po, '=>', p
-
             pos = 0
             n = 0
             for m in re.finditer(p, post, re.MULTILINE):