-
Notifications
You must be signed in to change notification settings - Fork 0
/
clearall.py
43 lines (37 loc) · 1.22 KB
/
clearall.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
#!python2
#coding:utf-8
import xml.etree.cElementTree as ET
import sys
import re
import os
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 clear(pumpfile):
root = ET.parse(pumpfile).getroot()
for node in root:
dest = node.get("dest")
if os.path.exists(dest):
print("delete %s" % dest)
os.remove(dest)
if __name__ == "__main__":
excludes = ['inttools']
includes = ["../Libs"]
parsefiles = []
Search(".","parselist.xml", excludes, parsefiles)
for include in includes:
Search(include, "parselist.xml", excludes, parsefiles)
for parsefile in parsefiles:
clear(parsefile)
pumpfiles = []
Search(".","pumplist.xml", excludes, pumpfiles)
for include in includes:
Search(include, "pumplist.xml", excludes, pumpfiles)
for pumpfile in pumpfiles:
clear(pumpfile)