euscan-ng/pym/euscan/handlers/sourceforge.py
volpino 0124465806 euscan: Improving Berlios and Sourceforge handlers
Signed-off-by: volpino <fox91@anche.no>
2012-08-08 12:20:33 +02:00

36 lines
879 B
Python

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
PRIORITY = 90
def can_handle(pkg, url=None):
return url and "sourceforge.net/" in url
def scan_url(pkg, url, options):
output.einfo("Using SourceForge handler")
cp, ver, rev = portage.pkgsplit(pkg.cpv)
project, filename = re.search("sourceforge.net/([^/]+)/(?:.*/)?([^/]+)",
url).groups()
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 = []
for found_url, pv, _, _ in result:
ret.append((found_url, pv, HANDLER_NAME, CONFIDENCE))
return ret