-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathupdate_presets.py
41 lines (34 loc) · 1.4 KB
/
update_presets.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
import glob
import json
presets = []
for preset_category_idx, preset_category_path in enumerate(
glob.glob('presets/*')):
preset_category_name = preset_category_path.split('/')[1]
preset_category_data = {
'idx': preset_category_idx,
'name': preset_category_name,
'subcategories': [],
}
for subcategory_preset_idx, subcategory_preset_path in enumerate(
glob.glob(preset_category_path + '/*.txt')):
preset_subcategory = subcategory_preset_path.split('/')[2].split(
'.')[0]
preset_subcategory_data = {
'id': subcategory_preset_idx,
'name': preset_subcategory,
'presets': []
}
with open(subcategory_preset_path, 'r') as subcategory_preset_file:
subcategory_presets = subcategory_preset_file.read().splitlines()
for subcategory_idx, subcategory_preset in enumerate(
subcategory_presets):
subcategory_preset_data = {
'id': subcategory_idx,
'name': subcategory_preset
}
preset_subcategory_data['presets'].append(
subcategory_preset_data)
preset_category_data['subcategories'].append(preset_subcategory_data)
presets.append(preset_category_data, )
with open("presets.json", "w") as presets_file:
json.dump(presets, presets_file)