aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorentin Chary <corentincj@iksaif.net>2011-08-31 15:38:32 +0200
committerCorentin Chary <corentincj@iksaif.net>2011-08-31 15:38:32 +0200
commit752fb04425831cb9430b0924c74c29bad43130b0 (patch)
tree4454de99b62028396314a46fbcb057c321eb6945 /pym/euscan/handlers/pypi.py
parenteuscan: better blacklists (diff)
downloadeuscan-752fb04425831cb9430b0924c74c29bad43130b0.tar.gz
euscan-752fb04425831cb9430b0924c74c29bad43130b0.tar.bz2
euscan-752fb04425831cb9430b0924c74c29bad43130b0.zip
euscan: shake the code
- add custom site handlers - use a custom user agent - fix some bugs in management commands Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Diffstat (limited to 'pym/euscan/handlers/pypi.py')
-rw-r--r--pym/euscan/handlers/pypi.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/pym/euscan/handlers/pypi.py b/pym/euscan/handlers/pypi.py
new file mode 100644
index 0000000..59f7046
--- /dev/null
+++ b/pym/euscan/handlers/pypi.py
@@ -0,0 +1,51 @@
+import xmlrpclib
+import pprint
+import re
+
+import portage
+
+from euscan import helpers, output
+
+def can_handle(cpv, url):
+ return url.startswith('mirror://pypi/')
+
+def guess_package(cp, url):
+ match = re.search('mirror://pypi/\w+/(.*)/.*', url)
+ if match:
+ return match.group(1)
+
+ cat, pkg = cp.split("/")
+
+ return pkg
+
+def scan(cpv, url):
+ 'http://wiki.python.org/moin/PyPiXmlRpc'
+
+
+ package = guess_package(cpv, url)
+
+ output.einfo("Using PyPi XMLRPC: " + package)
+
+ 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 = []
+
+ for version in versions:
+ if helpers.version_filtered(cp, ver, version):
+ continue
+ urls = client.release_urls(package, version)
+ urls = " ".join([ infos['url'] for infos in urls ])
+ ret.append(( urls, version ))
+
+ return ret
+
+def brute_force(cpv, url):
+ return []