euscan: add kde handler and fix some regex issues

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
This commit is contained in:
Corentin Chary
2011-12-30 11:34:39 +01:00
parent d673c00e12
commit b78e73038d
4 changed files with 50 additions and 7 deletions

View File

@ -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:

View File

@ -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)

View 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)