Skip to content

Commit 2f2adde

Browse files
Website, Issues: local_replace.py general improvements.
* simplified the regular expressions, three into one. * only allowing one space after r|rev|revision * better test order to reflect the order of regexs * tests: indicate in the comment what should fail
1 parent 44ef48f commit 2f2adde

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

website/issues/extensions/local_replace.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
'<a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=\g<id>">debian#\g<id></a>' ),
55
(re.compile('\#(?P<ws>\s*)(?P<id>\d+)'),
66
"<a href='issue\g<id>'>#\g<ws>\g<id></a>" ),
7-
(re.compile('(?P<prews>\s+)revision(?P<ws>\s*)(?P<revision>\d+)'),
8-
"\g<prews><a href='http://svn.roundup-tracker.org/viewvc/roundup?view=rev&rev=\g<revision>'>revision\g<ws>\g<revision></a>"),
9-
(re.compile('(?P<prews>\s+)rev(?P<ws>\s*)(?P<revision>\d+)'),
10-
"\g<prews><a href='http://svn.roundup-tracker.org/viewvc/roundup?view=rev&rev=\g<revision>'>rev\g<ws>\g<revision></a>"),
11-
(re.compile('(?P<prews>\s+)(?P<revstr>r|r\s+)(?P<revision>\d+)'),
7+
(re.compile('(?P<prews>\s+)(?P<revstr>(revision|rev|r)\s?)(?P<revision>\d+)'),
128
"\g<prews><a href='http://svn.roundup-tracker.org/viewvc/roundup?view=rev&rev=\g<revision>'>\g<revstr>\g<revision></a>"),
139
]
1410

@@ -26,8 +22,11 @@ def init(instance):
2622

2723
if "__main__" == __name__:
2824
print " debian:#222", local_replace(" debian:#222")
25+
print " #555", local_replace(" #555")
2926
print " revision 222", local_replace(" revision 222")
30-
print " wordthatendswithr 222", local_replace(" wordthatendswithr 222")
31-
print " r222", local_replace(" r222")
3227
print " r 222", local_replace(" r 222")
33-
print " #555", local_replace(" #555")
28+
print " wordthatendswithr 222", local_replace(" wordthatendswithr 222") # should fail
29+
print " too many spaces r 222", local_replace(" too many spaces r 222") # should fail
30+
print " r7140eb", local_replace(" r7140eb")
31+
print " rev7140eb", local_replace(" rev7140eb")
32+
print " rev7140eb", local_replace(" rev7140eb")

0 commit comments

Comments
 (0)