2012-08-07 16:42:27 +02:00
|
|
|
import re
|
|
|
|
|
|
|
|
import portage
|
|
|
|
|
|
|
|
from euscan.helpers import regex_from_template
|
|
|
|
from euscan.handlers.url import process_scan as url_scan
|
|
|
|
from euscan import output
|
|
|
|
|
|
|
|
HANDLER_NAME = "sourceforge"
|
|
|
|
CONFIDENCE = 90
|
2012-08-07 16:45:28 +02:00
|
|
|
PRIORITY = 90
|
2012-08-07 16:42:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
def can_handle(pkg, url=None):
|
2012-08-15 11:04:29 +02:00
|
|
|
return url and "mirror://sourceforge/" in url
|
2012-08-07 16:42:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
def scan_url(pkg, url, options):
|
|
|
|
output.einfo("Using SourceForge handler")
|
|
|
|
|
|
|
|
cp, ver, rev = portage.pkgsplit(pkg.cpv)
|
|
|
|
|
2012-08-15 11:04:29 +02:00
|
|
|
project, filename = re.search("mirror://sourceforge/([^/]+)/(?:.*/)?([^/]+)",
|
2012-08-08 12:20:33 +02:00
|
|
|
url).groups()
|
2012-08-07 16:42:27 +02:00
|
|
|
base_url = "http://qa.debian.org/watch/sf.php/%s" % project
|
|
|
|
file_pattern = regex_from_template(
|
|
|
|
filename.replace(ver, "${PV}")
|
|
|
|
)
|
|
|
|
|
|
|
|
result = url_scan(pkg, base_url, file_pattern)
|
|
|
|
|
|
|
|
ret = []
|
2012-08-15 11:04:29 +02:00
|
|
|
for url, pv, _, _ in result:
|
|
|
|
ret.append((url, pv, HANDLER_NAME, CONFIDENCE))
|
2012-08-07 16:42:27 +02:00
|
|
|
return ret
|