pypi_package_info/main.py

23 lines
601 B
Python
Raw Normal View History

2020-04-02 19:46:52 -07:00
#!/bin/python3
2020-04-02 17:41:09 -07:00
import requests
2020-04-02 19:46:52 -07:00
import sys
2020-04-02 17:41:09 -07:00
from jinja2 import Template
def package(package_name, template):
url = 'https://pypi.org/pypi/{}/json'.format(package_name)
info = dict(requests.get(url).json())
test_template = Template(open(template).read())
print(test_template.render(
version=info["info"]["version"],
2020-04-02 19:53:52 -07:00
name=info["info"]["name"],
2020-04-02 17:41:09 -07:00
summary=info["info"]["summary"],
home_page=info["info"]["home_page"],
2020-04-02 19:59:46 -07:00
sha256=info["releases"][info["info"]["version"]][0]["digests"]["sha256"],
license=info["info"]["license"]))
2020-04-02 19:46:52 -07:00
if __name__ == "__main__":
package(sys.argv[1], sys.argv[2])