-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.py
34 lines (24 loc) · 803 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
import requests
import json
def getGoogleCloudServiceListApi():
product_list = []
url = "https://danishi.github.io/gc-service-list-api/products.json"
response = requests.get(url)
data = response.json()
names = [item['name'] for item in data['items']]
for name in names:
incorrect = []
if ' ' in name:
incorrect.append(name.replace(' ', ''))
product = {
"correct": name,
"incorrect": incorrect
}
product_list.append(product)
return product_list
def saveJsonFile(product_list):
with open('./src/terms.json', 'w') as file:
json.dump(product_list, file, indent=2)
if __name__ == "__main__":
product_list = getGoogleCloudServiceListApi()
saveJsonFile(product_list)