diff --git a/pym/euscan/handlers/__init__.py b/pym/euscan/handlers/__init__.py index f729fa2..0008535 100644 --- a/pym/euscan/handlers/__init__.py +++ b/pym/euscan/handlers/__init__.py @@ -1,9 +1,6 @@ -from euscan.handlers import generic -from euscan.handlers import php -from euscan.handlers import pypi -from euscan.handlers import rubygem +from euscan.handlers import generic, php, pypi, rubygem, kde -handlers = [ php, pypi, rubygem, generic ] +handlers = [ kde, php, pypi, rubygem, generic ] def find_best_handler(cpv, url): for handler in handlers: diff --git a/pym/euscan/handlers/generic.py b/pym/euscan/handlers/generic.py index 9a4b7c3..fbae5a0 100644 --- a/pym/euscan/handlers/generic.py +++ b/pym/euscan/handlers/generic.py @@ -18,6 +18,7 @@ def scan_html(data, url, pattern): href = link.get("href") if not href: continue + if href.startswith(url): href = href.replace(url, "", 1) diff --git a/pym/euscan/handlers/kde.py b/pym/euscan/handlers/kde.py new file mode 100644 index 0000000..eb7fbd8 --- /dev/null +++ b/pym/euscan/handlers/kde.py @@ -0,0 +1,34 @@ +from euscan.handlers import generic + +def can_handle(cpv, url): + if url.startswith('mirror://kde/'): + return True + return False + +def clean_results(results): + ret = [] + + for path, version in results: + if version == '5SUMS': + continue + ret.append((path, version)) + + return ret + +def scan(cpv, url): + results = generic.scan(cpv, url) + + if url.startswith('mirror://kde/unstable/'): + url = url.replace('mirror://kde/unstable/', 'mirror://kde/stable/') + results += generic.scan(cpv, url) + + return clean_results(results) + +def brute_force(cpv, url): + results = generic.brute_force(cpv, url) + + if url.startswith('mirror://kde/unstable/'): + url = url.replace('mirror://kde/unstable/', 'mirror://kde/stable/') + results += generic.brute_force(cpv, url) + + return clean_results(results) diff --git a/pym/euscan/helpers.py b/pym/euscan/helpers.py index 49d1fe5..cad098b 100644 --- a/pym/euscan/helpers.py +++ b/pym/euscan/helpers.py @@ -334,16 +334,26 @@ def tryurl(fileurl, template): return result def regex_from_template(template): + # Escape template = re.escape(template) + + # Unescape specific stuff template = template.replace('\$\{', '${') template = template.replace('\}', '}') template = template.replace('}\.$', '}.$') - template = template.replace('${1}', r'([\d]+?)') - template = re.sub(r'(\$\{\d+\}\.?)+', r'([\w]+?)', template) + + # Replace ${\d+} + #template = template.replace('${0}', r'([\d]+?)') + template = re.sub(r'(\$\{\d+\}(\.?))+', r'([\w\.]+?)', template) + #template = re.sub(r'(\$\{\d+\}\.?)+', r'([\w]+?)', template) #template = re.sub(r'(\$\{\d+\}\.+)+', '(.+?)\.', template) #template = re.sub(r'(\$\{\d+\})+', '(.+?)', template) + + # Full version template = template.replace('${PV}', _v) + + # End template = template + r'/?$' return template @@ -372,6 +382,7 @@ def generate_scan_paths(url): else: path += "/" path += chunk + return steps def parse_mirror(uri):