I looked at the pypi classifiers and some guide to help me write the following script, and here's me wondering if it can be improved:
import xmlrpc.client
# pypi language version classifiers
PY3 = ["Programming Language :: Python :: 3"]
PY2 = ["Programming Language :: Python :: 2"]
PY27 = ["Programming Language :: Python :: 2.7"]
PY26 = ["Programming Language :: Python :: 2.6"]
PY25 = ["Programming Language :: Python :: 2.5"]
PY24 = ["Programming Language :: Python :: 2.4"]
PY23 = ["Programming Language :: Python :: 2.3"]
def main():
client = xmlrpc.client.ServerProxy('http://pypi.python.org/pypi')
# get module metadata
py3names = [name[0] for name in client.browse(PY3)]
py2names = [name[0] for name in client.browse(PY2)]
py27names = [name[0] for name in client.browse(PY27)]
py26names = [name[0] for name in client.browse(PY26)]
py25names = [name[0] for name in client.browse(PY25)]
py24names = [name[0] for name in client.browse(PY24)]
py23names = [name[0] for name in client.browse(PY23)]
cnt = 0
for py3name in py3names:
if py3name not in py27names \
and py3name not in py26names \
and py3name not in py25names \
and py3name not in py24names \
and py3name not in py23names \
and py3name not in py2names:
cnt += 1
print("Python3-only packages: {}".format(cnt))
main()
Sidenote:
$ time python3 py3k-only.py
Python3-only packages: 259
real 0m17.312s
user 0m0.324s
sys 0m0.012s
In addition, can you spot any functionality bugs in there? Will it give accurate results, assuming that pypi has correct info?