Commits

Ezio Melotti  committed 441435c

Factor out some code and fix a couple of bugs.

  • Participants
  • Parent commits e2c6cb5

Comments (0)

Files changed (2)

File extensions/local_replace.py

 
 # these regexs have test in tests/test_local_replace.py
 
+seps = r'\b(?<![-/?&;=_])'  # these chars should not precede the targets
 substitutions = [
     # deadbeeffeed  (hashes with exactly twelve or forty chars)
-    (re.compile(r'\b(?<![/?&;=])(?P<revision>[a-fA-F0-9]{40})\b'),
+    (re.compile(r'%s(?P<revision>[a-fA-F0-9]{40})\b' % seps),
      r'<a href="http://hg.python.org/lookup/\g<revision>">\g<revision></a>'),
-    (re.compile(r'\b(?<![/?&;=])(?P<revision>[a-fA-F0-9]{12})\b'),
+    (re.compile(r'%s(?P<revision>[a-fA-F0-9]{12})\b' % seps),
      r'<a href="http://hg.python.org/lookup/\g<revision>">\g<revision></a>'),
 
     # r12345, r 12345, rev12345, rev. 12345, revision12345, revision 12345
-    (re.compile(r'\b(?<![/?&;])(?P<revstr>r\.?(ev\.?(ision)?)?\s*)(?P<revision>\d{4,})'),
+    (re.compile(r'%s(?P<revstr>r\.?(ev\.?(ision)?)?\s*)(?P<revision>\d{4,})' % seps),
      r'<a href="http://hg.python.org/lookup/r\g<revision>">\g<revstr>\g<revision></a>'),
 
     # Lib/somefile.py, Lib/somefile.py:123, Modules/somemodule.c:123, ...
      make_traceback_link),
 
     # PEP 8, PEP8, PEP 0008, ...
-    (re.compile(r'\b(?<![/=-])PEP\s*(\d{1,4})(?!/)\b', re.I),
+    (re.compile(r'%s\b(?<![/=-])PEP\s*(\d{1,4})(?!/)\b' % seps, re.I),
      make_pep_link),
 
     # devguide
-    (re.compile(r'(?<!/)(devguide(?:/\w+(?:.html)?(?:#[\w-]+)?)?)'),
+    (re.compile(r'%s(devguide(?:/\w+(?:.html)?(?:#[\w-]+)?)?)' % seps),
      r'<a href="http://docs.python.org/\1">\1</a>'),
 ]
 

File extensions/test/local_replace_data.txt

 see <a href="http://docs.python.org/whatsnew/2.6.html#pep-371-the-multiprocessing-package">http://docs.python.org/whatsnew/2.6.html#pep-371-the-multiprocessing-package</a>
 http://bugs.python.org/file24624/Proposed-fix-of-issue14099-second.patch
 <a href="http://bugs.python.org/file24624/Proposed-fix-of-issue14099-second.patch">http://bugs.python.org/file24624/Proposed-fix-of-issue14099-second.patch</a>
+http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&displaylang=en
+<a href="http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&amp;displaylang=en">http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&amp;displaylang=en</a>
+http://hg.python.org/sandbox/morph-devguide/shortlog/a92d431ef749
+<a href="http://hg.python.org/sandbox/morph-devguide/shortlog/a92d431ef749">http://hg.python.org/sandbox/morph-devguide/shortlog/a92d431ef749</a>
 ##
 ## tracebacks
 File "/usr/lib/python2.7/socket.py", line 553, in create_connection