aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'grumpy/vdb/pypi.py')
-rw-r--r--grumpy/vdb/pypi.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/grumpy/vdb/pypi.py b/grumpy/vdb/pypi.py
new file mode 100644
index 0000000..2e27059
--- /dev/null
+++ b/grumpy/vdb/pypi.py
@@ -0,0 +1,45 @@
+from lxml.html import fromstring
+import urllib
+
+class PyPi(object):
+ # TODO: Shall we use some kind of yaml or json based format instead?
+ # Or move this data into DB?
+ pkgs = {
+ # Package in Portage : Package in PyPi
+ 'dev-python/flask' : 'Flask',
+ 'dev-python/flask-openid' : 'Flask-OpenID',
+ 'dev-python/flask-sqlalchemy' : 'Flask-SQLAlchemy',
+ 'dev-python/mako' : 'Mako',
+ 'dev-python/sphinx' : 'Sphinx',
+ 'dev-python/virtualenv' : 'virtualenv',
+ 'dev-python/vobject' : 'vobject',
+ 'dev-python/werkzeug' : 'Werkzeug',
+ 'dev-python/xlwt' : 'xlwt',
+ 'dev-python/yolk' : 'yolk',
+ 'dev-python/yolk-portage' : 'yolk-portage',
+ }
+
+ # Url for fetching version information
+ url = 'http://pypi.python.org/pypi?:action=index'
+
+ def __init__(self):
+ pass
+
+ def fetch_and_parse_all(self):
+ """Download and parse package version information."""
+
+ items = {}
+ #f = urllib.urlopen(self.url)
+ f = open('utils/pypi.html')
+ if f:
+ data = fromstring(f.read()).cssselect('table.list')[0]
+ for row in data.getchildren():
+ val = row[0].getchildren()
+ if len(val) > 0:
+ pkg = val[0].text.encode('utf-8').split('\xc2\xa0')
+ if len(pkg) == 2:
+ if pkg[0] not in items.keys():
+ items[pkg[0]] = []
+ items[pkg[0]].append(pkg[1])
+ f.close()
+ return items