aboutsummaryrefslogtreecommitdiff
blob: 752dba9d2868d49ed43af7bac1c52c734b6c2206 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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 "mirror://sourceforge/" in url


def scan_url(pkg, url, options):
    output.einfo("Using SourceForge handler")

    cp, ver, rev = portage.pkgsplit(pkg.cpv)

    project, filename = re.search("mirror://sourceforge/([^/]+)/(?:.*/)?([^/]+)",
                                  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 url, pv, _, _ in result:
        ret.append((url, pv, HANDLER_NAME, CONFIDENCE))
    return ret