#encoding=utf-8
import os,re
def checkline(path, str):
#print(str)
result = res(str)
if result is 1:
fileobj = open(path+"\\codestatistic.html", 'r', encoding='utf-8')
elif result is 2:
fileobj = open(path+"\\complex.html", 'r', encoding='utf-8')
elif result is 3:
fileobj = open(path+"\\ftCoverage.html", 'r', encoding='utf-8')
elif result is 4:
fileobj = open(path+"\\pclint.html", 'r', encoding='utf-8')
else:
fileobj = None
return fileobj
'''
if str == detail:
print(1)
fileobj = open(path, "codestatistic.html", 'r', encoding='utf-8')
elif str == comparison:
print(2)
fileobj = open(path, "complex.html", 'r', encoding='utf-8')
elif str == result:
print(3)
fileobj = open(path, "ftCoverage.html", 'r', encoding='utf-8')
elif str == audit:
print(4)
fileobj = open(path, "ftCoverage.html", 'r', encoding='utf-8')
else:
'''
def readandrewrite(path, filename):
abspath = os.path.join(path, filename)
print(path)
fileobj = open(path + "\\TempletHtml.html", 'r', encoding='utf-8')
lines = fileobj.readlines()
fileobj2 = open(path + "\\temp.html", "w", encoding='utf-8')
for line in lines:
flag = checkline(path, line)
if flag != None:
contents = flag.readlines()
fileobj2.writelines("<div>")
for content in contents:
print("content is" + content)
fileobj2.write(content)
fileobj2.writelines("</div>")
flag.close()
else:
fileobj2.writelines(line)
fileobj2.close()
fileobj.close()
#os.remove(path + "temp.html")
return
def res(str1):
detail = "<div>FailureDetails</div>"
comparison = "<div>ZDBcomparison</div"
result = "<div>CheckScriptResult</div>"
audit = "<div>AuditResult</div>"
pattern = re.compile(detail)
match = pattern.match(str1)
if match:
return 1
pattern = re.compile(comparison)
match = pattern.match(str1)
if match:
return 2
pattern = re.compile(result)
match = pattern.match(str1)
if match:
return 3
pattern = re.compile(audit)
match = pattern.match(str1)
if match:
return 4
return None
'''
if line is "<div>FailureDetails</div>":
fileobj3 = open(path,"codestatistic.html")
contents = fileobj3.readlines()
for content in contents:
fileobj2.writelines(content)
fileobj3.close()
elif line is "<div>ZDBcomparison</div>":
fileobj3 = open(path,"complex.html")
contents = fileobj3.readlines()
for content in contents:
fileobj2.writelines(content)
fileobj3.close()
elif line is "<div>CheckScriptResult</div>":
fileobj3 = open(path,"ftCoverage.html")
contents = fileobj3.readlines()
for content in contents:
fileobj2.writelines(content)
fileobj3.close()
elif line is "<div>AuditResult</div>":
fileobj3 = open(path,"pclint.html")
contents = fileobj3.readlines()
for content in contents:
fileobj2.writelines(content)
fileobj3.close()
else:
fileobj2.writelines(line)
'''
def main():
readandrewrite("E:\\scripts", "TempletHtml.html")
if __name__ == "__main__":
main()
import os,re
def checkline(path, str):
#print(str)
result = res(str)
if result is 1:
fileobj = open(path+"\\codestatistic.html", 'r', encoding='utf-8')
elif result is 2:
fileobj = open(path+"\\complex.html", 'r', encoding='utf-8')
elif result is 3:
fileobj = open(path+"\\ftCoverage.html", 'r', encoding='utf-8')
elif result is 4:
fileobj = open(path+"\\pclint.html", 'r', encoding='utf-8')
else:
fileobj = None
return fileobj
'''
if str == detail:
print(1)
fileobj = open(path, "codestatistic.html", 'r', encoding='utf-8')
elif str == comparison:
print(2)
fileobj = open(path, "complex.html", 'r', encoding='utf-8')
elif str == result:
print(3)
fileobj = open(path, "ftCoverage.html", 'r', encoding='utf-8')
elif str == audit:
print(4)
fileobj = open(path, "ftCoverage.html", 'r', encoding='utf-8')
else:
'''
def readandrewrite(path, filename):
abspath = os.path.join(path, filename)
print(path)
fileobj = open(path + "\\TempletHtml.html", 'r', encoding='utf-8')
lines = fileobj.readlines()
fileobj2 = open(path + "\\temp.html", "w", encoding='utf-8')
for line in lines:
flag = checkline(path, line)
if flag != None:
contents = flag.readlines()
fileobj2.writelines("<div>")
for content in contents:
print("content is" + content)
fileobj2.write(content)
fileobj2.writelines("</div>")
flag.close()
else:
fileobj2.writelines(line)
fileobj2.close()
fileobj.close()
#os.remove(path + "temp.html")
return
def res(str1):
detail = "<div>FailureDetails</div>"
comparison = "<div>ZDBcomparison</div"
result = "<div>CheckScriptResult</div>"
audit = "<div>AuditResult</div>"
pattern = re.compile(detail)
match = pattern.match(str1)
if match:
return 1
pattern = re.compile(comparison)
match = pattern.match(str1)
if match:
return 2
pattern = re.compile(result)
match = pattern.match(str1)
if match:
return 3
pattern = re.compile(audit)
match = pattern.match(str1)
if match:
return 4
return None
'''
if line is "<div>FailureDetails</div>":
fileobj3 = open(path,"codestatistic.html")
contents = fileobj3.readlines()
for content in contents:
fileobj2.writelines(content)
fileobj3.close()
elif line is "<div>ZDBcomparison</div>":
fileobj3 = open(path,"complex.html")
contents = fileobj3.readlines()
for content in contents:
fileobj2.writelines(content)
fileobj3.close()
elif line is "<div>CheckScriptResult</div>":
fileobj3 = open(path,"ftCoverage.html")
contents = fileobj3.readlines()
for content in contents:
fileobj2.writelines(content)
fileobj3.close()
elif line is "<div>AuditResult</div>":
fileobj3 = open(path,"pclint.html")
contents = fileobj3.readlines()
for content in contents:
fileobj2.writelines(content)
fileobj3.close()
else:
fileobj2.writelines(line)
'''
def main():
readandrewrite("E:\\scripts", "TempletHtml.html")
if __name__ == "__main__":
main()