-
Notifications
You must be signed in to change notification settings - Fork 0
/
parseall.py
50 lines (44 loc) · 1.5 KB
/
parseall.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
#!python2
#!coding:utf-8
import xml.etree.cElementTree as ET
import sys
import re
import os
def NeedPump(model, tpl, dest):
if not os.path.exists(dest):
return True
destMtime = os.stat(dest).st_mtime
if os.stat(tpl).st_mtime > destMtime:
return True
for item in model.split(" "):
if os.stat(item).st_mtime > destMtime:
return True
return False
def Search(path, destFileName, excludes, destPaths):
for fileName in os.listdir(path):
if fileName in excludes:
continue
fullFileName = os.path.join(path, fileName)
if os.path.isfile(fullFileName) and fileName == destFileName:
destPaths.append(fullFileName)
if os.path.isdir(fullFileName):
Search(fullFileName, destFileName, excludes, destPaths)
def DoParse(fileName):
root = ET.parse(fileName).getroot()
for node in root:
script = node.get("script")
sources = node.get("sources")
dest = node.get("dest")
if NeedPump(sources, script, dest):
print("%s %s %s" % (script, dest, sources))
if os.system("python %s %s %s" % (script, dest, sources)) != 0:
exit()
if __name__ == "__main__":
excludes = ['.sv', '.vs', 'build', 'out']
includes = ["../Libs"]
parsefiles = []
Search(".", "parselist.xml", excludes, parsefiles)
for include in includes:
Search(include, "parselist.xml", excludes, parsefiles)
for parsefile in parsefiles:
DoParse(parsefile)