Skip to content

Instantly share code, notes, and snippets.

@toutpt
Created December 9, 2012 20:16
Show Gist options
  • Save toutpt/4246806 to your computer and use it in GitHub Desktop.
Save toutpt/4246806 to your computer and use it in GitHub Desktop.
my pypi release
import xmlrpclib
import pprint
client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
packs = client.user_packages('toutpt')
infos = []
BLACKLIST = [
'epwithgis.openlayers',
'pasteFunBot',
'Products.AROfficeTransforms',
'gprof2dot',
'Products.ARFilePreview',
'Products.ImageEditor',
'collective.idashboard',
'mfabrik.plonezohointegration',
'Products.CallProfiler',
'webcouturier.dropdownmenu',
'collective.ckeditor',
]
mypacks = [package[1] for package in packs if package[0] == 'Owner' and package[1] not in BLACKLIST]
total_releases = 0
total_downloads = 0
for package in mypacks:
info = {'id':package, 'releases': 0, 'downloads': 0}
releases = client.package_releases(package, True)
for release in releases:
urls = client.release_urls(package, release)
if not urls:
continue
for url in urls:
info['releases'] += 1
info['downloads'] += url.get('downloads',0)
total_releases += 1
total_downloads += url.get('downloads',0)
infos.append(info)
TPL = """<tr><td><a href="http://pypi.python.org/pypi/%(id)s">%(id)s</a></td><td>%(releases)s</td/><td>%(downloads)s</td></tr>\n"""
f = open('mypypi.html', 'w')
f.write('<html><title>my pypi releases</title><body><table class="listing">')
f.write(TPL%{'id': 'package name', 'releases':'releases', 'downloads': 'downloads'})
for info in infos:
f.write(TPL%info)
f.write(TPL%{'id':'totals', 'releases': total_releases, 'downloads':total_downloads})
f.write('</table></body></html>')
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment