Last active
March 19, 2019 14:58
-
-
Save bskinn/a607efdf8732e969563d86e6466fdbaf to your computer and use it in GitHub Desktop.
Quick script for listing all "flake8*" packages on PyPI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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