1. Robot Mirror
  2. bugs.python.org

Commits

ezio.melotti  committed 8295b17

Refactor the regex list, use one regex for [r,rev,revision], add comments, indent properly, avoid long lines.

  • Participants
  • Parent commits 28551fb
  • Branches default

Comments (0)

Files changed (1)

File extensions/local_replace.py

View file
 import re
 
-substitutions = [ (re.compile(r'\#(?P<ws>\s*)(?P<id>\d+)'),
-                   r'<a href="issue\g<id>">#\g<ws>\g<id></a>'),
-                  (re.compile(r'\brevision(?P<ws>\s*)(?P<revision>\d+)'),
-                   r'<a href="http://svn.python.org/view?rev=\g<revision>&view=rev">revision\g<ws>\g<revision></a>'),
-                  (re.compile(r'\brev(?P<ws>\s*)(?P<revision>\d+)'),
-                   r'<a href="http://svn.python.org/view?rev=\g<revision>&view=rev">rev\g<ws>\g<revision></a>'),
-                  (re.compile(r'\b(?P<revstr>r|r\s+)(?P<revision>\d+)'),
-                   r'<a href="http://svn.python.org/view?rev=\g<revision>&view=rev">\g<revstr>\g<revision></a>'),
-                  (re.compile(r'\b(?P<path>(?:Demo|Doc|Grammar|Include|Lib|Mac|Misc|Modules|Parser|PC|PCbuild|Python|RISCOS|Tools|Objects)/[-.a-zA-Z0-9_/]+[a-zA-Z0-9]/?)'),
-                   r'<a href="http://svn.python.org/view/python/trunk/\g<path>">\g<path></a>'),
-                   ]
+substitutions = [
+    #  #1234, # 1234
+    (re.compile(r'\#(?P<ws>\s*)(?P<id>\d+)'),
+    r'<a href="issue\g<id>">#\g<ws>\g<id></a>'),
+    #  r12345, r 12345, rev12345, rev 12345, revision12345, revision 12345
+    (re.compile(r'\b(?P<revstr>r(ev(ision)?)?\s*)(?P<revision>\d+)'),
+    r'<a href="http://svn.python.org/view?rev=\g<revision>&view=rev">\g<revstr>\g<revision></a>'),
+    # Lib/somefile.py, Modules/somemodule.c, Doc/somedocfile.rst, ...
+    (re.compile(r'\b(?P<path>(?:Demo|Doc|Grammar|Include|Lib|Mac|Misc|Modules|Parser|PC|'
+                r'PCbuild|Python|RISCOS|Tools|Objects)/[-.a-zA-Z0-9_/]+[a-zA-Z0-9]/?)'),
+    r'<a href="http://svn.python.org/view/python/trunk/\g<path>">\g<path></a>'),
+]
 
 def localReplace(message):
     """