euscan: add kde handler and fix some regex issues
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
This commit is contained in:
parent
d673c00e12
commit
b78e73038d
@ -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:
|
||||
|
@ -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)
|
||||
|
||||
|
34
pym/euscan/handlers/kde.py
Normal file
34
pym/euscan/handlers/kde.py
Normal file
@ -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)
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user