-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathupdate-jazzy-yaml.py
43 lines (35 loc) · 1.68 KB
/
update-jazzy-yaml.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
import yaml
import os
def list_index_dict_with_name(l, name):
for index, entry in enumerate(l):
if entry['name'] == name:
return index
return None
def walk_dir(name, into_groups):
groups = into_groups
for root, directories, files in os.walk(name):
for file in files:
if file.endswith(".swift"):
file = file.split(".swift")[0]
components = root.split("/")
category = " ".join(components)
index = list_index_dict_with_name(groups, category)
if index is not None:
groups[index]['children'].append(file)
else:
groups.append({'name': category, 'children': [file]})
return groups
import shutil
print("Writing .jazzy-base.yaml to .jazzy.yaml")
shutil.copy(".jazzy-base.yaml", ".jazzy.yaml")
print("Generating directory representation")
path_hierarchy_app = walk_dir("JenkinsiOS", [])
path_hierarchy_all = walk_dir("JenkinsiOSTodayExtension", path_hierarchy_app)
with open('.jazzy.yaml', 'a') as f:
print("Writing representation to .jazzy.yaml")
f.write("""\n
#############################################################################################################################################
### This is an auto-generated file! To edit the above, please edit .jazzy-base.yaml, to edit custom_categories, please edit update-jazzy-yaml.py!
#############################################################################################################################################\n\n""")
yaml.dump({'custom_categories': path_hierarchy_all}, f, default_flow_style=False)
print('Done!')