Buckets:
ktongue/docker_container / .vscode-server /extensions /ms-python.vscode-python-envs-1.22.0 /build /validate_packages.py
| # Usage: | |
| # Windows: type package_list.txt | python validate_packages.py > valid_packages.txt | |
| # Linux/Mac: cat package_list.txt | python validate_packages.py > valid_packages.txt | |
| import json | |
| import sys | |
| import urllib | |
| import urllib.request as url_lib | |
| def _get_pypi_package_data(package_name): | |
| json_uri = "https://pypi.org/pypi/{0}/json".format(package_name) | |
| # Response format: https://warehouse.readthedocs.io/api-reference/json/#project | |
| # Release metadata format: https://github.com/pypa/interoperability-peps/blob/master/pep-0426-core-metadata.rst | |
| with url_lib.urlopen(json_uri) as response: | |
| return json.loads(response.read()) | |
| def validate_package(package): | |
| try: | |
| data = _get_pypi_package_data(package) | |
| num_versions = len(data["releases"]) | |
| return num_versions > 1 | |
| except urllib.error.HTTPError: | |
| return False | |
| if __name__ == "__main__": | |
| packages = sys.stdin.read().splitlines() | |
| valid_packages = [] | |
| for pkg in packages: | |
| if validate_package(pkg): | |
| print(pkg) | |
| valid_packages.append(pkg) | |
Xet Storage Details
- Size:
- 1.09 kB
- Xet hash:
- 66fa534e19a5d2f5f55d10b3ee4de0daf53b3c7d2cb39e93c7da21444e6182a2
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.