Skip to content

Instantly share code, notes, and snippets.

@bskinn
Last active March 19, 2019 14:58
Show Gist options
  • Save bskinn/a607efdf8732e969563d86e6466fdbaf to your computer and use it in GitHub Desktop.
Save bskinn/a607efdf8732e969563d86e6466fdbaf to your computer and use it in GitHub Desktop.
Quick script for listing all "flake8*" packages on PyPI
import json
import re
import requests as rq
pat = re.compile(b'href="/simple/([^/]+)/">')
req = rq.get('https://pypi.org/simple')
for mch in pat.finditer(req.content):
pkg = mch.group(1).decode()
if pkg.startswith("flake8"):
try:
req_pkg = rq.get("https://pypi.org/pypi/{}/json".format(pkg))
except Exception:
print("{}: JSON DOWNLOAD FAILED".format(pkg))
continue
if req_pkg.ok:
try:
msg = json.loads(req_pkg.content)['info']['summary']
except Exception:
print("{}: SUMMARY SEARCH FAILED".format(pkg))
else:
print("{}: {}".format(pkg, msg))
else:
print("{}: JSON API PAGE NOT FOUND".format(pkg))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment