-
Notifications
You must be signed in to change notification settings - Fork 3
/
bmi-index-builder.py
executable file
·34 lines (28 loc) · 1.1 KB
/
bmi-index-builder.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
#!/usr/bin/env python3
import logging
import requests
import os
import pickle
import time
import json
allfiles = os.listdir('.')
mods = []
for fil in allfiles:
if fil == ".git":
continue
if os.path.isdir(os.path.join(os.path.abspath('.'), fil)):
with open(os.path.join(os.path.abspath('.'),fil,'mod.json'),'r') as modfile:
print(os.path.join(os.path.abspath('.'),fil,'mod.json'))
print(fil)
modjson = modfile.read()
mod = json.loads(modjson)
mod['Name'] = fil
mods.append(mod)
modlistdict = {}
for mod in mods:
print(mod['Name'])
modlistdict[mod['Name']] = { 'Name': mod['Name'], 'Author': mod['Author'], 'Website': mod['Website'], 'Category': mod['Category'] if 'Category' in mod else 'Unknown', 'Description': mod['Description'] }
os.remove(os.path.join(os.path.abspath('.'),'modlist.json'))
with open(os.path.join(os.path.abspath('.'),'modlist.json'),'w') as modlistfile:
modlistfile.write(json.dumps(modlistdict, indent=4))
print(json.dumps(modlistdict, indent=4))