-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathreload.py
55 lines (40 loc) · 1.01 KB
/
reload.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
43
44
45
46
47
48
49
50
51
52
53
54
55
import json
import os
def main():
result_widgets = []
with open('marketplace.json') as file:
data = json.load(file)
print('current config:')
print(data)
size_mapper = {}
for widget in data['widgets']:
if widget['size'] == '':
continue
size_mapper[widget['name']] = widget['size']
print('size mapper:')
print(size_mapper)
for dir in os.listdir('widgets'):
if dir.startswith('.'):
continue
print(dir)
name = dir
size = 'small'
if name in size_mapper:
size = size_mapper[name]
result_widgets.append({
"name": name,
"size": size,
})
print('output widgets:')
print(result_widgets)
output_data = {
"name": "ScriptWidget Marketplace",
"maintainer": "everettjf",
"widgets": result_widgets
}
output_text = json.dumps(output_data, indent=4)
with open('marketplace.json', 'w') as file:
file.write(output_text)
print('Done :)')
if __name__ == "__main__":
main()