forked from e-ucm/eadventure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
refresh-resources.py
49 lines (43 loc) · 1.46 KB
/
refresh-resources.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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
import os
import shutil
import sys
import subprocess
# Find files with a certain extension
# do something with them later
def find_and_do(src_dir_name, pattern, callback):
pattern = pattern or "R\.java$"
def look(dir_name, dir_contents, callback):
for name in dir_contents:
source = os.path.join(dir_name, name)
if (os.path.isdir(source)):
look(source, os.listdir(source), callback)
elif (re.search(pattern, source) is not None):
callback(source)
look(src_dir_name, os.listdir(src_dir_name), callback)
return
def main():
def regen(source):
f = open(source, 'r')
d = f.read();
if (re.search('(.*)/src/.*', source) is None):
print "[ignoring bad match " + source + "]"
return;
project = re.search('(.*)/src/.*', source).group(1);
package = re.search('package (.*);', d).group(1);
f.close()
print ("=== processing" +
"\n\t" + source +
"\n\t" + project +
"\n\t" + package + "===>")
subprocess.call(["java",
"-cp", "core/editor-core/target/classes",
"es.eucm.ead.editor.util.i18n.ResourceCreator",
project, package,
"etc/LICENSE.txt"
# ,])
,source])
find_and_do("core/editor-core", False, regen)
main()