euscanwww: Removing useless stuff while creating watch tag

* Removing useless options or actions
* Fixing handling of substitution regex

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino
2012-07-25 10:19:27 +02:00
committed by Corentin Chary
parent e2890c6364
commit 9f164ed22c
2 changed files with 21 additions and 7 deletions

View File

@ -26,7 +26,11 @@ def can_handle(pkg, url):
def parse_mangles(mangles, string):
for mangle in mangles:
# convert regex from perl format to python format
# there are some regex in this format: s/pattern/replacement/
m = re.match(r"s/(.*[^\\])/(.*)/", mangle)
if not m:
# or in this format s|pattern|replacement|
m = re.match(r"s\|(.*[^\\])\|(.*)\|", mangle)
pattern, repl = m.groups()
repl = re.sub(r"\$(\d+)", r"\\\1", repl)
string = re.sub(pattern, repl, string)