-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformat.py
executable file
·54 lines (46 loc) · 1.13 KB
/
format.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
#!/usr/bin/env python
#Formats all code using js-beautify to enforce a standard style
from subprocess import call
import os
import sys
if (len(sys.argv) > 1 and sys.argv[1] == "templates"):
include = {
"dir": ["src"],
"file": ["roomtemplates.js"]
}
exclude = {
"dir": [],
"file": []
}
else:
include = {
"dir": ["src"],
"file": []
}
exclude = {
"dir": ["lib", "pixi"],
"file": ["require.js"]
}
def is_exclude(root, file):
for d in include["dir"]:
if d not in root:
return True
for f in include["file"]:
if f not in file:
return True
for d in exclude["dir"]:
if d in root:
return True
for f in exclude["file"]:
if f in file:
return True
return False
formatted = 0
for root, dirs, files in os.walk("."):
for file in files:
if is_exclude(root, file):
continue;
path = os.path.join(root, file)
print("Formatting " + path)
call("python ./format/js-beautify -r -n " + path, shell=True)
formatted += 1