import shutil,os
from lxml import etree
filePath = "E:\\S1"
def FindLevel3Window(filePath):
fillDict = {"isWindow" : False, "fileName" : ""}
html = etree.parse(filePath, etree.HTMLParser())
result = html.xpath('//@skinname')
for attr in result:
ReplaceStr(str(attr), "/", "S1", "S2")
if attr == "skins.ThirdPanelSkin3" or attr == "skins.ThirdPanelSkin3_Scacle":
fillDict["isWindow"] = True
fillDict["fileName"] = filePath
return fillDict
def FindAppointStr(strInfo, appointStr):
for str in strInfo:
if str == appointStr:
return True
return False
def ReplaceStr(str1, splitStr, findStr, replaceStr):
if isinstance(str1, str) and isinstance(splitStr, str):
str2 = ""
strInfo = str1.split(splitStr)
print(len(strInfo))
for attr in strInfo:
if attr == findStr:
attr = replaceStr
str2 = str2 + attr + "/"
print(str2)
else:
print("Erro: The input is not a character")
def TraverseAllFile(filePath):
fileTotal = 0
file_dir = os.walk(filePath, topdown=True)
for path,dir_list,file_list in file_dir:
pathInfo = path.split("\\")
isAppointStr = FindAppointStr(pathInfo, "S1")
if isAppointStr:
for file_name in file_list:
pathName = os.path.join(path, file_name)
fillDict = FindLevel3Window(pathName)
if fillDict["isWindow"]:
fileTotal = fileTotal + 1
print(fillDict["fileName"])
print(u"fileTotal num:", fileTotal)
if __name__ == '__main__':
TraverseAllFile(filePath)
11-07
434