diff --git a/bin/euscan_patch_metadata b/bin/euscan_patch_metadata
index 0de4239..642b639 100755
--- a/bin/euscan_patch_metadata
+++ b/bin/euscan_patch_metadata
@@ -166,16 +166,26 @@ def patch_metadata(metadata_path, watch_data, diff=False):
watch_line
)
- attrs_quote, attrs, url = result.groups()
- attrs = attrs_quote or attrs
+ opts_quote, opts, url = result.groups()
+ opts = opts_quote or opts
- if attrs:
- attrs = [x.replace('=', '="') + '"' for x in attrs.split(",")]
- attrs = " ".join(attrs)
+ if opts:
+ # clean opts, skip useless ones
+ valid = ("uversionmangle", "versionmangle", "downloadurlmangle")
+ cleaned_opts = []
+ for opt in opts.split(","):
+ opt_name, opt_value = opt.split("=")
+ if opt_name in valid:
+ cleaned_opts.append('%s="%s"' % (opt_name, opt_value))
+ opts = " ".join(cleaned_opts)
- if attrs:
+ # clean url from useless stuff. Just keep []
+ url_search = re.search(r"^([^\s]+)(?: ([^\s]*\([^\s]+\)[^\s]*))?", url)
+ url = " ".join([x for x in url_search.groups() if x is not None])
+
+ if opts:
watch_tag = '%s%s' % \
- (indent, version, attrs, url)
+ (indent, version, opts, url)
else:
watch_tag = '%s%s' % \
(indent, version, url)
diff --git a/pym/euscan/handlers/watch.py b/pym/euscan/handlers/watch.py
index d172072..a129281 100644
--- a/pym/euscan/handlers/watch.py
+++ b/pym/euscan/handlers/watch.py
@@ -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)