Mercurial > p > roundup > code
diff website/issues/extensions/local_replace.py @ 4866:a5222e7ac94b
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
| author | Bernhard Reiter <bernhard@intevation.de> |
|---|---|
| date | Thu, 13 Mar 2014 09:49:14 +0100 |
| parents | 7140ebfc3764 |
| children | 3737662fd96b |
line wrap: on
line diff
--- a/website/issues/extensions/local_replace.py Thu Mar 13 09:22:57 2014 +0100 +++ b/website/issues/extensions/local_replace.py Thu Mar 13 09:49:14 2014 +0100 @@ -4,11 +4,7 @@ '<a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=\g<id>">debian#\g<id></a>' ), (re.compile('\#(?P<ws>\s*)(?P<id>\d+)'), "<a href='issue\g<id>'>#\g<ws>\g<id></a>" ), - (re.compile('(?P<prews>\s+)revision(?P<ws>\s*)(?P<revision>\d+)'), - "\g<prews><a href='http://svn.roundup-tracker.org/viewvc/roundup?view=rev&rev=\g<revision>'>revision\g<ws>\g<revision></a>"), - (re.compile('(?P<prews>\s+)rev(?P<ws>\s*)(?P<revision>\d+)'), - "\g<prews><a href='http://svn.roundup-tracker.org/viewvc/roundup?view=rev&rev=\g<revision>'>rev\g<ws>\g<revision></a>"), - (re.compile('(?P<prews>\s+)(?P<revstr>r|r\s+)(?P<revision>\d+)'), + (re.compile('(?P<prews>\s+)(?P<revstr>(revision|rev|r)\s?)(?P<revision>\d+)'), "\g<prews><a href='http://svn.roundup-tracker.org/viewvc/roundup?view=rev&rev=\g<revision>'>\g<revstr>\g<revision></a>"), ] @@ -26,8 +22,11 @@ if "__main__" == __name__: print " debian:#222", local_replace(" debian:#222") + print " #555", local_replace(" #555") print " revision 222", local_replace(" revision 222") - print " wordthatendswithr 222", local_replace(" wordthatendswithr 222") - print " r222", local_replace(" r222") print " r 222", local_replace(" r 222") - print " #555", local_replace(" #555") + print " wordthatendswithr 222", local_replace(" wordthatendswithr 222") # should fail + print " too many spaces r 222", local_replace(" too many spaces r 222") # should fail + print " r7140eb", local_replace(" r7140eb") + print " rev7140eb", local_replace(" rev7140eb") + print " rev7140eb", local_replace(" rev7140eb")
