forked from fengbird/JavaWebCoreNote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
61 lines (40 loc) · 1.22 KB
/
run.py
File metadata and controls
61 lines (40 loc) · 1.22 KB
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
#!/usr/bin/python
import os,re,sys,string
try:
lang = str(sys.argv[1])
except IndexError:
lang=""
print "lang: " + lang
if (not(lang == '')):
langsuffix = "_" + lang
langparam = "lang=" + lang
langsuffixparam = "langsuffix=" + langsuffix
else:
langsuffix = ""
langparam = ""
langsuffixparam = ""
if re.compile("Python\Z").search(os.getcwd()):
os.chdir("..")
def compactXMLsources():
os.chdir("SourceXML")
data=''
for f in os.listdir('.'):
if not(re.compile("\.xml\Z").search(f)):
continue
id = re.compile("\d+").search(f).group(0)
input=open(f)
xxx=input.read()
xxx = re.compile("<\w+").sub("\n\g<0> id='"+id+"' ",xxx,1)
data = data + xxx
input.close()
os.chdir('..')
output=open('Data' +langsuffix+ '/xmlSources.xml','w')
output.write('<!-- generated by run.py -->\n<xm_sources>\n'+data+'\n</xm_sources>')
output.close()
compactXMLsources()
#
# use saxon5 here! saxon6 has some bugs!
#
command = 'saxon5 -o Output' + langsuffix + '/index.html Data' + langsuffix + '/xmlSources.xml XSLT/stylesheet.xslt pwd=${PWD}/ ' + langparam +" "+ langsuffixparam
print "command: " + command
os.system(command)