def __init__(self, template, target, information):
        super(TraceTable, self).__init__(template)
        nodes = self.dom.childNodes

        element = findElementById(nodes, "traceTable")

        print(information)
        for key in sorted(information):
            rowElement = self.dom.createElement("tr")

            cellElement = self.dom.createElement("td")
            cellElement.appendChild(self.dom.createTextNode(key))
            rowElement.appendChild(cellElement)

            cellElement = self.dom.createElement("td")

            informationString = information[key].replace(" ", "")
            informationList = informationString.split(",")
            if len(informationList) > 1:
                informationList.pop(0)
            informationString = ", ".join(sorted(informationList))
            cellElement.appendChild(self.dom.createTextNode(informationString))
            rowElement.appendChild(cellElement)

            element.appendChild(rowElement)

        # write table of contents

        targetFile = open(target, "w")
        targetFile.write(self.dom.toxml())
        targetFile.close()
Beispiel #2
0
    def __init__(self, sections, categoryStatus, categoryTitles):
        super(BookTOC,
              self).__init__("tools_configuration/BOOK_TOC_TEMPLATE.html")
        nodes = self.dom.childNodes

        project = Project()

        toc = project.projectName + "_toc.html"

        element = findElementById(nodes, "bookTitle")
        element.appendChild(
            self.dom.createTextNode(project.projectName +
                                    " - System Level Test Procedures"))

        orderedListNode = findElementById(nodes, "sectionList")
        firstListElement = orderedListNode.firstChild

        for category in sections:
            status = categoryStatus[category]
            listItemTag = self.dom.createElement("li")
            anchorTag = self.dom.createElement("a")
            titleLine = category + " - " + categoryTitles[category]

            anchorTag.setAttribute("href", category + "_toc.html")

            if status == "PASSED":
                anchorTag.setAttribute("style", "color: 00F000")
            else:
                if status == "FAILED":
                    anchorTag.setAttribute("style", "color: FF0000")

            anchorTag.appendChild(self.dom.createTextNode(titleLine))
            listItemTag.appendChild(anchorTag)
            orderedListNode.insertBefore(listItemTag, firstListElement)

        # write table of contents

        tocFile = open(toc, "w")
        tocFile.write(self.dom.toxml())
        tocFile.close()