Mercurial > public > mercurial-scm > hg-stable
diff contrib/check-code.py @ 10727:62b8f15683f2
check-code: more tests and more robust python filtering
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Thu, 18 Mar 2010 16:32:03 +0100 |
parents | 8ea152e94484 |
children | cd0c49bdbfd9 |
line wrap: on
line diff
--- 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 = [