-
Notifications
You must be signed in to change notification settings - Fork 11
/
generate.py
43 lines (26 loc) · 980 Bytes
/
generate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from urllib.request import urlopen
import json
import os
URL = "https://pypi.org/pypi/{package}/json"
# read add-on list
OFFICIAL_ADDONS = [a.strip() for a in open("OFFICIAL_ADDONS.txt", "rt")]
OFFICIAL_ADDONS = [a for a in OFFICIAL_ADDONS if a]
# query PyPI
package_list = []
for package in OFFICIAL_ADDONS:
r = urlopen(URL.format(package=package)).read().decode("utf-8")
p = json.loads(r)
package_list.append(p)
with open('list.tmp', 'wt') as f:
json.dump(package_list, f, sort_keys=True, indent=4)
# verification
with open('list.tmp', "rt") as f:
json_list = json.load(f)
names_in_json = [a["info"]["name"] for a in json_list]
assert names_in_json == OFFICIAL_ADDONS
# are the expected parts there?
for addon in json_list:
info = addon["info"]
_ = info["version"], info["summary"], info["description"], info["package_url"], info["package_url"]
# verification successful
os.rename('list.tmp', "list")