-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathres_codegen.py
executable file
·69 lines (58 loc) · 2.13 KB
/
res_codegen.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/python3
from os import walk
from os import getcwd
from sys import argv
from datetime import datetime
target_web = "res/web"
target_web_len_inc = len(target_web) + 1
target_dfl = "res/dfl"
target_dfl_len_inc = len(target_dfl) + 1
if len(argv) > 1:
target_web = argv[1]
target_web_len_inc = len(target_web) + 1
if len(argv) > 2:
target_dfl = argv[2]
target_dfl_len_inc = len(target_dfl) + 1
def list_dirs(t, tli):
lst_dir = ""
for curdir, _, _ in walk(t):
curdir = curdir[tli:]
if curdir == "":
curdir = "."
lst_dir += "\t\t\t\"{}\",\n".format(curdir)
return lst_dir[:len(lst_dir) - 2]
def list_files(t, tli):
lst_files = ""
for curdir, _, files in walk(t):
curdir = curdir[tli:]
if curdir != "":
curdir = "/{}".format(curdir)
for file in files:
lst_files += "\t\t\t\"{}/{}\",\n".format(curdir,file)
return lst_files[:len(lst_files) - 2]
print("/* java code generated by res_codegen.py ({}) script".format(argv[0]))
print(" * on {}, with the following settings:\n *".format(datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
print(" * -- target_web: {}".format(target_web))
print(" * -- target_dfl: {}".format(target_dfl))
print(" * -- working_dir: {}\n *\n */\n".format(getcwd()))
print("package logic;\n");
print("import java.util.Arrays;")
print("import java.util.List;\n")
print("public final class ExtractorFileLister {")
print("\tprivate ExtractorFileLister(){}\n")
print("\tpublic static List<String> listWebDirs() {")
print("\t\treturn Arrays.asList(")
print(list_dirs(target_web, target_web_len_inc))
print("\t\t);\n\t}\n")
print("\tpublic static List<String> listWebFiles() {")
print("\t\treturn Arrays.asList(")
print(list_files(target_web, target_web_len_inc))
print("\t\t);\n\t}\n")
print("\tpublic static List<String> listDflDirs() {")
print("\t\treturn Arrays.asList(")
print(list_dirs(target_dfl, target_dfl_len_inc))
print("\t\t);\n\t}\n")
print("\tpublic static List<String> listDflFiles() {")
print("\t\treturn Arrays.asList(")
print(list_files(target_dfl, target_dfl_len_inc))
print("\t\t);\n\t}\n}")