-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatchRepo.py
31 lines (24 loc) · 995 Bytes
/
patchRepo.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
import glob
import subprocess
import os
import sys
repoRoot='/home/lou/Public/ELTeC-'
patchDir='/home/lou/Public/Scripts/'
schemaFile='/home/lou/Public/Schemas/eltec-1.rng'
print("This is the name of the program:", sys.argv[0])
print("Argument List:", str(sys.argv))
if (len(sys.argv) <= 2) :
print("Please specify language repository and patch file\n e.g pythonRepo.py xxx wibble\n runs Scripts/wibble.xsl against each file in ELTeC-xxx")
else:
LANG=sys.argv[1]
PATCH=sys.argv[2]
patchFile=patchDir+PATCH+'.xsl'
repoName=repoRoot+LANG
print("Patching repo "+repoName+" with "+patchFile)
os.chdir(repoName)
FILES=sorted(glob.glob('level[01]/*.xml'))
for FILE in FILES:
os.rename(FILE,FILE+'.back')
print("File="+FILE)
command="saxon -s:" + repoName + "/" + FILE + ".back -xsl:" + patchFile + ' -o:'+FILE
subprocess.check_output(command,shell=True)