Created
September 17, 2017 04:51
-
-
Save jonemo/a1c0f4768f2c0aa25e31388c0fd6e377 to your computer and use it in GitHub Desktop.
Python script to check which Python 3.6 standard library package names are registered 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 sys | |
import requests | |
print(f"Package Name,exists?,HTTP code,Author,Maintainer,registered by op?") | |
for package_name in sys.stdin: | |
package_name = package_name.strip() | |
resp_json = requests.get(f"https://pypi.org/pypi/{package_name}/json") | |
exists, sstagg, author, maintainer = False, False, '', '' | |
exists = resp_json.status_code == 200 | |
if exists: | |
# packages maintained by Stephen Stagg seem to have empty "info" fields | |
# in the json response, use html version instead where the name gets | |
# mentioned (for not having a Gravatar) | |
resp_html = requests.get(f"https://pypi.org/project/{package_name}") | |
sstagg = 'Stephen.Stagg' in resp_html.text | |
author = resp_json.json().get('info', {}).get('author_email', '') | |
maintainer = resp_json.json().get('info', {}).get('maintainer_email', '') | |
print(f"{package_name},{exists},{resp_json.status_code},{author},{maintainer},{sstagg}") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment