2011-08-31 15:38:32 +02:00
|
|
|
import xmlrpclib
|
|
|
|
import re
|
|
|
|
|
|
|
|
import portage
|
|
|
|
|
2011-12-12 15:15:00 +01:00
|
|
|
from euscan import helpers
|
|
|
|
import euscan
|
2011-08-31 15:38:32 +02:00
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-08-31 15:38:32 +02:00
|
|
|
def can_handle(cpv, url):
|
|
|
|
return url.startswith('mirror://pypi/')
|
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-08-31 15:38:32 +02:00
|
|
|
def guess_package(cp, url):
|
|
|
|
match = re.search('mirror://pypi/\w+/(.*)/.*', url)
|
|
|
|
if match:
|
|
|
|
return match.group(1)
|
|
|
|
|
|
|
|
cat, pkg = cp.split("/")
|
|
|
|
|
|
|
|
return pkg
|
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-08-31 15:38:32 +02:00
|
|
|
def scan(cpv, url):
|
|
|
|
'http://wiki.python.org/moin/PyPiXmlRpc'
|
|
|
|
|
|
|
|
package = guess_package(cpv, url)
|
|
|
|
|
2011-12-12 15:15:00 +01:00
|
|
|
euscan.output.einfo("Using PyPi XMLRPC: " + package)
|
2011-08-31 15:38:32 +02:00
|
|
|
|
|
|
|
client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
|
|
|
|
versions = client.package_releases(package)
|
|
|
|
|
|
|
|
if not versions:
|
|
|
|
return versions
|
|
|
|
|
|
|
|
versions.reverse()
|
|
|
|
|
|
|
|
cp, ver, rev = portage.pkgsplit(cpv)
|
|
|
|
|
|
|
|
ret = []
|
|
|
|
|
2012-04-19 15:36:44 +02:00
|
|
|
for up_pv in versions:
|
|
|
|
pv = helpers.gentoo_mangle_version(up_pv)
|
|
|
|
if helpers.version_filtered(cp, ver, pv):
|
2011-08-31 15:38:32 +02:00
|
|
|
continue
|
2012-04-19 15:36:44 +02:00
|
|
|
urls = client.release_urls(package, up_pv)
|
2012-04-28 18:16:05 +02:00
|
|
|
urls = " ".join([infos['url'] for infos in urls])
|
|
|
|
ret.append((urls, pv))
|
2011-08-31 15:38:32 +02:00
|
|
|
|
|
|
|
return ret
|
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-08-31 15:38:32 +02:00
|
|
|
def brute_force(cpv, url):
|
|
|
|
return []
|