def run(param): #read xml file scriptsDir = os.getcwd() os.chdir(mafPath.mafQADir) baseDir = os.getcwd() qaResultsDir = os.path.join(baseDir, "QAResults") xmlDir = os.path.join(baseDir, "QAResults", "xml") if not os.path.exists(xmlDir): print "Xml Directory not present: ", xmlDir sys.exit(1) htmlDir = os.path.join(baseDir, "QAResults", "html") if not os.path.exists(htmlDir): os.makedirs(htmlDir) if not os.path.exists(os.path.join(htmlDir, "Styles")): os.makedirs(os.path.join(htmlDir, "Styles")) if (os.path.exists(os.path.join(htmlDir, "Styles"))): origDir = os.path.join(scriptsDir, "Styles") destDir = os.path.join(htmlDir, "Styles") files = os.listdir(origDir) for item in files: if (item != 'CVS' and item != 'SVN' and item != '.cvs' and item != '.svn'): shutil.copyfile(os.path.join(origDir, item), os.path.join(destDir, item)) xmlList = os.listdir(xmlDir) htmlList = [file.replace(".xml", ".html") for file in os.listdir(xmlDir)] ruleLinksString = "" for link in htmlList: if (link != "index.html" and link != "Styles"): ruleLinksString = ruleLinksString + "<li><a href=\"" + link + "\">" + link[:link.find( ".")] + "</a></li>\n" xsltH = """<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:template name="break"> <xsl:param name="text"/> <xsl:choose> <xsl:when test="contains($text, '
')"> <xsl:value-of select="substring-before($text, '
')"/> <br/> <xsl:call-template name="break"> <xsl:with-param name="text" select="substring-after($text,'
')"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="/">""" xsltT = """ </xsl:template> </xsl:stylesheet> """ headString = "".join(open(os.path.join(htmlDir, "Styles", "head.temp"))) headString = headString.replace("@@@_PUBLISH_DATE_@@@", str(datetime.now().date())) centerString = "".join(open(os.path.join(htmlDir, "Styles", "center.temp"))) tailString = "".join(open(os.path.join(htmlDir, "Styles", "tail.temp"))) #check for external scripting pos = 0 pos = headString.find("@@@_EXTERNAL_TOOLS_REPORT_@@@") - 1 if (param['LCOVCoverage']): #generateExternalLink externalScriptDirectory = os.path.join(scriptsDir, "ExternalScripts") #os.chdir(externalScriptDirectory) os.system( "python " + os.path.join(externalScriptDirectory, "LCOVCoveragePublish.py")) li = "<li><a href=\"../externalLCOVCoverage/index.html\">LCOV Coverage</a></li>" headString = headString[:pos] + li + headString[pos:] pos = pos + len(li) #os.chdir(scriptsDir) if (param['cppcheck']): #generateExternalLink externalScriptDirectory = os.path.join(scriptsDir, "ExternalScripts") #os.chdir(externalScriptDirectory) os.system("python " + os.path.join(externalScriptDirectory, "cppcheckPublish.py")) li = "<li><a href=\"../externalcppcheck/index.html\">Static Analysis</a></li>" headString = headString[:pos] + li + headString[pos:] pos = pos + len(li) #os.chdir(scriptsDir) if (param['cccc']): #generateExternalLink externalScriptDirectory = os.path.join(scriptsDir, "ExternalScripts") #os.chdir(externalScriptDirectory) os.system("python " + os.path.join(externalScriptDirectory, "ccccPublish.py")) li = "<li><a href=\"../externalcccc/index.html\">Code Complexity</a></li>" headString = headString[:pos] + li + headString[pos:] pos = pos + len(li) #os.chdir(scriptsDir) #remove placeholder for external scripting headString = headString.replace("@@@_EXTERNAL_TOOLS_REPORT_@@@", "") success = True for xmlFile in xmlList: try: filename = os.path.splitext(xmlFile)[0] print "Formatting in HTML " + filename #with lxml parse the file f = open(xmlDir + "/" + xmlFile, 'r') xml = fromstring(str(f.read())) #with lxml create html searchF = filename + ".xslt" absPathXslt = "" for top, dirs, files in os.walk('./'): for nm in files: if (nm == searchF): absPathXslt = os.path.join(top, nm) fileXslt = open(absPathXslt, 'r') #print xsltH + headString + centerString + str(fileXslt.read()) + tailString + xsltT xsl = fromstring(xsltH + headString + ruleLinksString + centerString + str(fileXslt.read()) + tailString + xsltT) style = XSLT(xsl) result = style.apply(xml) #print htmlDir + filename + ".html" html = open(os.path.join(htmlDir, filename + ".html"), 'w') print >> html, style.tostring(result) except Exception, e: success = False print "!!!!!!Bad Formatted XML on ", filename, "!!!!!!!" print e os.chdir(scriptsDir)
def publishReport(): extScriptDir = os.getcwd() os.chdir(qaDir) baseDir = os.getcwd() qaResultsDir = os.path.join(baseDir,"QAResults") htmlDir = os.path.join(baseDir,"QAResults","html") xmlDir = os.path.join(baseDir,"QAResults","xml") CPPCheckStaticAnalisysDir = os.path.join(qaResultsDir, "externalcppcheck") #need to parametrize this? reportFile = os.path.join(CPPCheckStaticAnalisysDir, "report.xml"); try: filename = reportFile print "Formatting in HTML " + filename #with lxml parse the file f = open(filename) xml = fromstring(str(f.read())) #with lxml create html absPathXslt = os.path.join(currentPathScript,"cppcheckPlugin.xslt") fileXslt = open(absPathXslt, 'r') #print xsltH + headString + centerString + str(fileXslt.read()) + tailString + xsltT xsl= fromstring(fileXslt.read().replace("@@@_PUBLISH_DATE_@@@", str( datetime.now().date()))) style = XSLT(xsl) result = style.apply(xml) #print htmlDir + filename + ".html" html = open(os.path.join(CPPCheckStaticAnalisysDir, "report.html"), 'w') print >> html , style.tostring(result) #create introduction for cppcheck headString = "".join(open(os.path.join(htmlDir, "Styles", "head.temp"))) headString = headString.replace("@@@_PUBLISH_DATE_@@@", str( datetime.now().date())) centerString = "".join(open(os.path.join(htmlDir,"Styles", "center.temp"))) tailString = "".join(open(os.path.join(htmlDir, "Styles", "tail.temp"))) #modify headstring adding cppcheck stylesheet, and substitute relative path pos = headString.find("</head>")-1 headStringNew = headString headStringNew = headString[:pos] + "<link rel=\"stylesheet\" type=\"text/css\" href=\"../html/Styles/gcov.css\">\n" + headString[pos:] headStringNew = headStringNew.replace("href=\"Styles/", "href=\"../html/Styles/") headStringNew = headStringNew.replace("<li><a href=\"index.html\">Introduction</a></li>", "<li><a href=\"../html/index.html\">Introduction</a></li>") headStringNew = headStringNew.replace("@@@_EXTERNAL_TOOLS_REPORT_@@@", "") #remove placeholder headStringNew = headStringNew.replace("Rule Scripts", "Static Analysis") fileIndex = open(os.path.join(CPPCheckStaticAnalisysDir, "index.html"), 'w'); fileIndex.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">") fileIndex.write(headStringNew) ruleLinksStringIndex = "<li><a href=\"" + "./report.html\">" + "Cppcheck Report" + "</a></li>\n" fileIndex.write(ruleLinksStringIndex) fileIndex.write(centerString) fileIndex.write(""" <h1> Static Analysis Using CPPCHECK</h1> Cppcheck is an analysis tool for C/C++ code. <br> Unlike C/C++ compilers and many other analysis tools, it don't detect syntax errors. <br> Cppcheck only detects the types of bugs that the compilers normally fail to detect. The goal is no false positives.<br> Currently the CPPCHECK version used is the 1.4.7, and the check has been executed on the root directory of the MAF framework.<br> <br>Some features:<br> <ul><li>Out of bounds checking <li>Check the code for each class</li> <li>Checking exception safety</li> <li>Memory leaks checking</li> <li>Warn if obsolete functions are used</li> <li>Check for invalid usage of STL</li> <li>Check for uninitialized variables and unused functions</li> </ul> <br> <h2> <a href="./report.html">Go to Report table</a> </h2> <br> """) fileIndex.write(tailString) fileIndex.close() except Exception, e: print "Problem when publishing cppcheck, error:" , e
def publishReport(): extScriptDir = os.getcwd() os.chdir(qaDir) baseDir = os.getcwd() qaResultsDir = os.path.join(baseDir, "QAResults") htmlDir = os.path.join(baseDir, "QAResults", "html") xmlDir = os.path.join(baseDir, "QAResults", "xml") CPPCheckStaticAnalisysDir = os.path.join( qaResultsDir, "externalcppcheck") #need to parametrize this? reportFile = os.path.join(CPPCheckStaticAnalisysDir, "report.xml") try: filename = reportFile print "Formatting in HTML " + filename #with lxml parse the file f = open(filename) xml = fromstring(str(f.read())) #with lxml create html absPathXslt = os.path.join(currentPathScript, "cppcheckPlugin.xslt") fileXslt = open(absPathXslt, 'r') #print xsltH + headString + centerString + str(fileXslt.read()) + tailString + xsltT xsl = fromstring(fileXslt.read().replace("@@@_PUBLISH_DATE_@@@", str(datetime.now().date()))) style = XSLT(xsl) result = style.apply(xml) #print htmlDir + filename + ".html" html = open(os.path.join(CPPCheckStaticAnalisysDir, "report.html"), 'w') print >> html, style.tostring(result) #create introduction for cppcheck headString = "".join(open(os.path.join(htmlDir, "Styles", "head.temp"))) headString = headString.replace("@@@_PUBLISH_DATE_@@@", str(datetime.now().date())) centerString = "".join( open(os.path.join(htmlDir, "Styles", "center.temp"))) tailString = "".join(open(os.path.join(htmlDir, "Styles", "tail.temp"))) #modify headstring adding cppcheck stylesheet, and substitute relative path pos = headString.find("</head>") - 1 headStringNew = headString headStringNew = headString[: pos] + "<link rel=\"stylesheet\" type=\"text/css\" href=\"../html/Styles/gcov.css\">\n" + headString[ pos:] headStringNew = headStringNew.replace("href=\"Styles/", "href=\"../html/Styles/") headStringNew = headStringNew.replace( "<li><a href=\"index.html\">Introduction</a></li>", "<li><a href=\"../html/index.html\">Introduction</a></li>") headStringNew = headStringNew.replace("@@@_EXTERNAL_TOOLS_REPORT_@@@", "") #remove placeholder headStringNew = headStringNew.replace("Rule Scripts", "Static Analysis") fileIndex = open(os.path.join(CPPCheckStaticAnalisysDir, "index.html"), 'w') fileIndex.write( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">" ) fileIndex.write(headStringNew) ruleLinksStringIndex = "<li><a href=\"" + "./report.html\">" + "Cppcheck Report" + "</a></li>\n" fileIndex.write(ruleLinksStringIndex) fileIndex.write(centerString) fileIndex.write(""" <h1> Static Analysis Using CPPCHECK</h1> Cppcheck is an analysis tool for C/C++ code. <br> Unlike C/C++ compilers and many other analysis tools, it don't detect syntax errors. <br> Cppcheck only detects the types of bugs that the compilers normally fail to detect. The goal is no false positives.<br> Currently the CPPCHECK version used is the 1.4.7, and the check has been executed on the root directory of the MAF framework.<br> <br>Some features:<br> <ul><li>Out of bounds checking <li>Check the code for each class</li> <li>Checking exception safety</li> <li>Memory leaks checking</li> <li>Warn if obsolete functions are used</li> <li>Check for invalid usage of STL</li> <li>Check for uninitialized variables and unused functions</li> </ul> <br> <h2> <a href="./report.html">Go to Report table</a> </h2> <br> """) fileIndex.write(tailString) fileIndex.close() except Exception, e: print "Problem when publishing cppcheck, error:", e
def publishReport(): extScriptDir = os.getcwd() os.chdir(qaDir) baseDir = os.getcwd() qaResultsDir = os.path.join(baseDir, "QAResults") htmlDir = os.path.join(baseDir, "QAResults", "html") xmlDir = os.path.join(baseDir, "QAResults", "xml") xmlList = os.listdir(xmlDir) htmlList = [file.replace(".xml", ".html") for file in os.listdir(xmlDir)] ccccExternalDir = qaResultsDir + "/externalcccc" #need to parametrize this? covList = os.listdir(ccccExternalDir) if (os.path.exists(htmlDir) == False): print "Html Results Dir doesn't exist %s" % htmlDir exit() if (os.path.exists(qaResultsDir) == False): print "cccc directory results doesn't exist %s" % ccccExternalDir exit() """if(os.path.exists(os.path.join(ccccExternalDir , "index.html"))): print "************************* Warning ******************************" print "cccc Report already Formatted, please remove directory and rerun Publishing script" print "************************* ------- ******************************" return """ stylePath = os.path.join(htmlDir, "Styles") headString = "".join(open(stylePath + "/head.temp")) headString = headString.replace("@@@_PUBLISH_DATE_@@@", str(datetime.now().date())) centerString = "".join(open(stylePath + "/center.temp")) tailString = "".join(open(stylePath + "/tail.temp")) #write here format xmlReports = [ item for item in os.listdir(ccccExternalDir) if (os.path.splitext(item)[1] == ".xml") ] ccccLinks = [(os.path.splitext(item)[0] + ".html") for item in xmlReports] ruleLinksStringIndex = "" for link in ccccLinks: ruleLinksStringIndex = ruleLinksStringIndex + "<li><a href=\"" + link + "\">" + link[: -9] + "</a></li>\n" try: for reportFile in xmlReports: #for each file apply stylesheet htmlName = os.path.join(ccccExternalDir, os.path.splitext(reportFile)[0] + ".html") print "Formatting in HTML " + htmlName #with lxml parse the file f = open(os.path.join(ccccExternalDir, reportFile)) xml = fromstring(str(f.read())) #with lxml create html absPathXslt = os.path.join(currentPathScript, "cccc.xslt") fileXslt = open(absPathXslt, 'r') #print xsltH + headString + centerString + str(fileXslt.read()) + tailString + xsltT xsl = fromstring(fileXslt.read().replace( "@@@_PUBLISH_DATE_@@@", str(datetime.now().date())).replace( " @@@_EXTERNAL_TOOLS_LINKS_@@@", ruleLinksStringIndex).replace( "@@@_EXTERNAL_TOOLS_REPORT_@@@", "")) style = XSLT(xsl) result = style.apply(xml) #print htmlDir + filename + ".html" html = open(os.path.join(ccccExternalDir, htmlName), 'w') print >> html, style.tostring(result) except Exception, e: print "Problem when publishing cccc , error:", e
def run(param): #read xml file scriptsDir = os.getcwd() os.chdir(medPath.medQADir) baseDir = os.getcwd() qaResultsDir = os.path.join(baseDir,"QAResults") xmlDir = os.path.join(baseDir,"QAResults","xml") if not os.path.exists(xmlDir): print "Xml Directory not present: ", xmlDir sys.exit(1) htmlDir = os.path.join(baseDir,"QAResults","html") if not os.path.exists(htmlDir): os.makedirs(htmlDir) if not os.path.exists(os.path.join(htmlDir,"Styles")): os.makedirs(os.path.join(htmlDir,"Styles")) if(os.path.exists(os.path.join(htmlDir,"Styles"))): origDir = os.path.join(scriptsDir, "Styles") destDir = os.path.join(htmlDir, "Styles") files = os.listdir(origDir) for item in files: if (item != 'CVS' and item != 'SVN' and item != '.cvs' and item != '.svn'): shutil.copyfile(os.path.join(origDir,item), os.path.join(destDir, item)) xmlList=os.listdir(xmlDir) htmlList=[file.replace(".xml", ".html") for file in os.listdir(xmlDir)] ruleLinksString = "" for link in htmlList: if(link != "index.html" and link != "Styles"): ruleLinksString = ruleLinksString + "<li><a href=\"" + link + "\">" + link[:link.find(".")] + "</a></li>\n" xsltH = """<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:template name="break"> <xsl:param name="text"/> <xsl:choose> <xsl:when test="contains($text, '
')"> <xsl:value-of select="substring-before($text, '
')"/> <br/> <xsl:call-template name="break"> <xsl:with-param name="text" select="substring-after($text,'
')"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="/">""" xsltT = """ </xsl:template> </xsl:stylesheet> """ headString = "".join(open(os.path.join(htmlDir,"Styles" ,"head.temp"))) headString = headString.replace("@@@_PUBLISH_DATE_@@@", str( datetime.now().date())) centerString = "".join(open(os.path.join(htmlDir,"Styles","center.temp"))) tailString = "".join(open(os.path.join(htmlDir, "Styles","tail.temp"))) #check for external scripting pos = 0 pos = headString.find("@@@_EXTERNAL_TOOLS_REPORT_@@@")-1 if(param['LCOVCoverage']): #generateExternalLink externalScriptDirectory = os.path.join(scriptsDir, "ExternalScripts") #os.chdir(externalScriptDirectory) os.system("python " + os.path.join(externalScriptDirectory, "LCOVCoveragePublish.py")) li = "<li><a href=\"../externalLCOVCoverage/index.html\">LCOV Coverage</a></li>"; headString = headString[:pos] + li + headString[pos:] pos = pos + len(li) #os.chdir(scriptsDir) if(param['cppcheck']): #generateExternalLink externalScriptDirectory = os.path.join(scriptsDir,"ExternalScripts") #os.chdir(externalScriptDirectory) os.system("python " + os.path.join(externalScriptDirectory,"cppcheckPublish.py")) li = "<li><a href=\"../externalcppcheck/index.html\">Static Analysis</a></li>" headString = headString[:pos] + li + headString[pos:] pos = pos + len(li) #os.chdir(scriptsDir) if(param['cccc']): #generateExternalLink externalScriptDirectory = os.path.join(scriptsDir,"ExternalScripts") #os.chdir(externalScriptDirectory) os.system("python " + os.path.join(externalScriptDirectory, "ccccPublish.py")) li = "<li><a href=\"../externalcccc/index.html\">Code Complexity</a></li>" headString = headString[:pos] + li + headString[pos:] pos = pos + len(li) #os.chdir(scriptsDir) #remove placeholder for external scripting headString = headString.replace("@@@_EXTERNAL_TOOLS_REPORT_@@@", "") success = True for xmlFile in xmlList: try: filename = os.path.splitext(xmlFile)[0] print "Formatting in HTML " + filename #with lxml parse the file f = open(xmlDir + "/" + xmlFile,'r') xml = fromstring(str(f.read())) #with lxml create html searchF = filename + ".xslt" absPathXslt = "" for top, dirs, files in os.walk('./'): for nm in files: if(nm == searchF): absPathXslt = os.path.join(top, nm) fileXslt = open(absPathXslt, 'r') #print xsltH + headString + centerString + str(fileXslt.read()) + tailString + xsltT xsl= fromstring(xsltH + headString + ruleLinksString + centerString + str(fileXslt.read()) + tailString + xsltT) style = XSLT(xsl) result = style.apply(xml) #print htmlDir + filename + ".html" html = open(os.path.join(htmlDir, filename + ".html"), 'w') print >> html , style.tostring(result) except Exception, e: success = False print "!!!!!!Bad Formatted XML on ", filename, "!!!!!!!" print e os.chdir(scriptsDir)
def publishReport(): extScriptDir = os.getcwd() os.chdir(qaDir) baseDir = os.getcwd() qaResultsDir = os.path.join(baseDir, "QAResults") htmlDir = os.path.join(baseDir, "QAResults","html") xmlDir = os.path.join(baseDir, "QAResults", "xml") xmlList=os.listdir(xmlDir) htmlList=[file.replace(".xml", ".html") for file in os.listdir(xmlDir)] ccccExternalDir = qaResultsDir + "/externalcccc" #need to parametrize this? covList = os.listdir(ccccExternalDir) if(os.path.exists(htmlDir) == False): print "Html Results Dir doesn't exist %s" % htmlDir exit() if(os.path.exists(qaResultsDir) == False): print "cccc directory results doesn't exist %s" % ccccExternalDir exit() """if(os.path.exists(os.path.join(ccccExternalDir , "index.html"))): print "************************* Warning ******************************" print "cccc Report already Formatted, please remove directory and rerun Publishing script" print "************************* ------- ******************************" return """ stylePath = os.path.join(htmlDir, "Styles") headString = "".join(open(stylePath + "/head.temp")) headString = headString.replace("@@@_PUBLISH_DATE_@@@", str( datetime.now().date())) centerString = "".join(open(stylePath + "/center.temp")) tailString = "".join(open(stylePath + "/tail.temp")) #write here format xmlReports = [item for item in os.listdir(ccccExternalDir) if (os.path.splitext( item )[1] == ".xml")] ccccLinks = [(os.path.splitext(item)[0] + ".html") for item in xmlReports] ruleLinksStringIndex = "" for link in ccccLinks: ruleLinksStringIndex = ruleLinksStringIndex + "<li><a href=\"" + link + "\">" + link[:-9] + "</a></li>\n" try: for reportFile in xmlReports: #for each file apply stylesheet htmlName = os.path.join(ccccExternalDir, os.path.splitext( reportFile )[0] + ".html") print "Formatting in HTML " + htmlName #with lxml parse the file f = open(os.path.join(ccccExternalDir,reportFile)) xml = fromstring(str(f.read())) #with lxml create html absPathXslt = os.path.join(currentPathScript,"ccccPlugin.xslt") fileXslt = open(absPathXslt, 'r') #print xsltH + headString + centerString + str(fileXslt.read()) + tailString + xsltT xsl = fromstring(fileXslt.read().replace("@@@_PUBLISH_DATE_@@@", str( datetime.now().date())).replace(" @@@_EXTERNAL_TOOLS_LINKS_@@@",ruleLinksStringIndex).replace("@@@_EXTERNAL_TOOLS_REPORT_@@@", "")) style = XSLT(xsl) result = style.apply(xml) #print htmlDir + filename + ".html" html = open(os.path.join(ccccExternalDir, htmlName), 'w') print >> html , style.tostring(result) except Exception, e: print "Problem when publishing cccc , error:" , e
def run(param): #read xml file scriptsDir = os.getcwd() os.chdir("../../") baseDir = os.getcwd() qaResultsDir = baseDir + "/QAResults/"; xmlDir = baseDir + "/QAResults/xml" if not os.path.exists(xmlDir): print "Xml Directory not present" sys.exit(1) htmlDir = baseDir + "/QAResults/html" if not os.path.exists(htmlDir): os.makedirs(htmlDir) if not os.path.exists(htmlDir+ "/Styles"): os.makedirs(htmlDir + "/Styles") if(os.path.exists(htmlDir + "/Styles")): shutil.rmtree(htmlDir + "/Styles") shutil.copytree(scriptsDir + "/Styles",htmlDir + "/Styles/") if(os.path.exists(htmlDir+ "/Styles/.svn")): for root, dirs, files in os.walk(htmlDir + "/Styles/.svn", topdown=False): for name in files: filename = os.path.join(root, name) os.chmod(filename, stat.S_IWUSR) os.remove(filename) for name in dirs: os.rmdir(os.path.join(root, name)) os.chmod(htmlDir + "/Styles/.svn", stat.S_IWUSR) os.rmdir(htmlDir + "/Styles/.svn") xmlList=os.listdir(xmlDir) htmlList=[file.replace(".xml", ".html") for file in os.listdir(xmlDir)] ruleLinksString = "" for link in htmlList: if(link != "index.html" and link != "Styles"): ruleLinksString = ruleLinksString + "<li><a href=\"" + link + "\">" + link[:link.find(".")] + "</a></li>\n" xsltH = """<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:template name="break"> <xsl:param name="text"/> <xsl:choose> <xsl:when test="contains($text, '
')"> <xsl:value-of select="substring-before($text, '
')"/> <br/> <xsl:call-template name="break"> <xsl:with-param name="text" select="substring-after($text,'
')"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="/">""" xsltT = """ </xsl:template> </xsl:stylesheet> """ headString = "".join(open(htmlDir + "/Styles/head.temp")) headString = headString.replace("@@@_PUBLISH_DATE_@@@", str( datetime.now().date())) centerString = "".join(open(htmlDir + "/Styles/center.temp")) tailString = "".join(open(htmlDir + "/Styles/tail.temp")) #check for external scripting if(param['LCOVCoverage']): #generateExternalLink externalScriptDirectory = scriptsDir + "/ExternalScripts" os.chdir(externalScriptDirectory) os.system("python " + externalScriptDirectory + "/LCOVCoveragePublish.py") pos = headString.find("@@@_EXTERNAL_TOOLS_REPORT_@@@")-1 os.chdir(scriptsDir); headString = headString[:pos] + "<li><a href=\"../externalLCOVCoverage/index.html\">LCOV Coverage</a></li>" + headString[pos:] #remove placeholder for external scripting headString = headString.replace("@@@_EXTERNAL_TOOLS_REPORT_@@@", "") result = True for xmlFile in xmlList: try: filename = os.path.splitext(xmlFile)[0] print "Formatting in HTML " + filename #with lxml parse the file f = open(xmlDir + "/" + xmlFile,'r') xml = fromstring(str(f.read())) #with lxml create html searchF = filename + ".xslt" absPathXslt = "" for top, dirs, files in os.walk('./'): for nm in files: if(nm == searchF): absPathXslt = os.path.join(top, nm) fileXslt = open(absPathXslt, 'r') #print xsltH + headString + centerString + str(fileXslt.read()) + tailString + xsltT xsl= fromstring(xsltH + headString + ruleLinksString + centerString + str(fileXslt.read()) + tailString + xsltT) style = XSLT(xsl) result = style.apply(xml) #print htmlDir + filename + ".html" html = open(htmlDir + "/" + filename + ".html", 'w') print >> html , style.tostring(result) except Exception, e: result = False print "!!!!!!Bad Formatted XML on ", filename , "!!!!!!!" print e os.chdir(scriptsDir)