diff options
author | 2012-09-14 16:21:30 +0200 | |
---|---|---|
committer | 2012-10-29 13:06:03 +0100 | |
commit | d2433c1b3c955fc86d3db8b2b1c6ea03a6e0e610 (patch) | |
tree | 4bde737d67ee1615b8a387d0816c402a2f3a8425 /pym | |
parent | euscanwww: Created a feed for scan world with packages in GET (diff) | |
download | euscan-d2433c1b3c955fc86d3db8b2b1c6ea03a6e0e610.tar.gz euscan-d2433c1b3c955fc86d3db8b2b1c6ea03a6e0e610.tar.bz2 euscan-d2433c1b3c955fc86d3db8b2b1c6ea03a6e0e610.zip |
euscan: Adding freecode handler
Uses experimental remote-id "freecode"
Signed-off-by: volpino <fox91@anche.no>
Diffstat (limited to 'pym')
-rw-r--r-- | pym/euscan/handlers/freecode.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/pym/euscan/handlers/freecode.py b/pym/euscan/handlers/freecode.py new file mode 100644 index 0000000..ebfe852 --- /dev/null +++ b/pym/euscan/handlers/freecode.py @@ -0,0 +1,48 @@ +import urllib +import re + +import portage + +from euscan import mangling, helpers, output + +HANDLER_NAME = "freecode" +CONFIDENCE = 100 +PRIORITY = 90 + + +def can_handle(pkg, url=None): + return False + + +def scan_pkg(pkg, options): + cp, ver, rev = portage.pkgsplit(pkg.cpv) + + package = options['data'] + + output.einfo("Using FreeCode handler: " + package) + + fp = urllib.urlopen("http://freecode.com/projects/%s/releases" % package) + content = fp.read() + + result = re.findall( + r'<a href="/projects/%s/releases/(\d+)">([^<]+)</a>' % package, + content + ) + + ret = [] + for release_id, up_pv in result: + pv = mangling.mangle_version(up_pv, options) + if helpers.version_filtered(cp, ver, pv): + continue + fp = urllib.urlopen("http://freecode.com/projects/%s/releases/%s" % + (package, release_id)) + content = fp.read() + download_page = re.findall(r'<a href="(/urls/[^"]+)"', content)[0] + fp = urllib.urlopen("http://freecode.com%s" % download_page) + content = fp.read() + url = re.findall( + r'In case it doesn\'t, click here: <a href="([^"]+)"', + content + )[0] + ret.append((url, pv, HANDLER_NAME, CONFIDENCE)) + return ret |