-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
47 lines (33 loc) · 1.4 KB
/
build.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
import os
import json
import sys
def check_prerequisites():
if sys.version_info[0] < 3 or sys.version_info[1] < 6:
raise Exception("Must be using Python 3.6 or later")
def build_layout(project_dir):
layout_entries = []
for root, _, files in os.walk(project_dir):
for filename in files:
filepath = os.path.join(root, filename)
if not "git" in filepath and not filepath.endswith(".txt") and not filepath.endswith(".md") and not filepath.endswith("layout.json") and not filepath.endswith("manifest.json") and not filepath.endswith(".py"):
rel_dir = os.path.relpath(root)
rel_file = str(os.path.join(rel_dir, filename))
if rel_file[0] == '.':
rel_file = rel_file[2:]
print(" -- Processing " + rel_file)
entry = {}
entry["path"] = rel_file.replace('\\', '/')
entry["size"] = os.path.getsize(filepath)
entry["date"] = "132402817714110148"
layout_entries.append(entry)
layout_entries.sort(key=lambda e: e["path"])
return layout_entries
if __name__ == "__main__":
check_prerequisites()
cwd = os.getcwd()
layout_content = build_layout(cwd)
layout_json = {
"content": layout_content
}
with open("layout.json", "w") as outfile:
json.dump(layout_json, outfile, indent=4)