Пример #1
0
    def render(self, level, idPrefix="") -> htmltree.HtmlElement:
        """Renders the Timeseries into a graph and places that Image into an html Img tag and returns a div
        containing that image and the images caption if it has one stored."""

        figName = self.plot()
        if self.encode:
            img = htmltree.Img(
                src=encode64(os.path.abspath(figName)),
                alt="{}_image".format(self.title),
                id=idPrefix,
            )
        else:
            htmltree.Img(
                src=os.path.abspath(figName),
                alt="{}_image".format(self.title),
                id=idPrefix,
            )
        return htmltree.Div(
            img,
            htmltree.P(self.caption),
        )
Пример #2
0
    def render(self, level, idPrefix="") -> htmltree.HtmlElement:
        """Wraps an image file into an html Img tag. (With caption included in the figure)"""

        figure = htmltree.Figure()
        if self.encode:
            self.imagePath = encode64(os.path.abspath(self.imagePath))
        figure.C.append(
            htmltree.Img(src=self.imagePath,
                         alt="{}_image".format(self.caption),
                         id=idPrefix))
        figure.C.append(htmltree.Figcaption(self.caption))
        return figure
Пример #3
0
    def writeReports(self):
        """Renders each report into a document for viewing."""

        body = htmltree.Body()
        head = htmltree.Head()

        head.C.append(htmltree.Link(rel="stylesheet", href="styles.css"))

        divMain = htmltree.Div(id="container")
        header = htmltree.Div(id="heading")
        header.C.append(
            htmltree.Img(
                src="https://terrapower.github.io/armi/_images/armi-logo.png",
                alt="logo",
                _class="heading",
            )
        )
        header.C.append(
            htmltree.H1(
                "{} Report".format(armi.context.APP_NAME.capitalize()),
                _class="heading",
                id="titleFont",
            )
        )

        divMain.C.append(header)
        div = htmltree.Div(id="reportContent")
        div.C.append(htmltree.H4("Report Generated for : " + self.title))
        body.C.append(self.tableOfContents())
        for group in self.sections:
            div.C.append(htmltree.H1(group, id=group))
            for subgroup in self.sections[group].childContents:
                innerDiv = htmltree.Div()
                if isinstance(self.sections[group][subgroup], htmltree.HtmlElement):
                    fig = self.sections[group].childContents[subgroup].render()
                else:
                    fig = (
                        self.sections[group]
                        .childContents[subgroup]
                        .render(0, str(group) + str(subgroup))
                    )
                innerDiv.C.append(fig)
                div.C.append(innerDiv)
        divMain.C.append(div)
        body.C.append(divMain)
        body.C.append(htmltree.Script(src="report.js"))

        doc = htmltree.Html(head, body)

        # Copy css file to the correct folder containing the reportContent.html
        shutil.copy(
            os.path.abspath(
                os.path.join(os.path.abspath(__file__), os.pardir, "styles.css")
            ),
            "styles.css",
        )

        shutil.copy(
            os.path.abspath(
                os.path.join(os.path.abspath(__file__), os.pardir, "report.js")
            ),
            "report.js",
        )
        fileurl = doc.renderToFile("index.html", 0)
        return fileurl