Passed
Pull Request — master (#149)
by Jan
04:11
created

oval_graph._builder_html_report   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 47.62%

Importance

Changes 0
Metric Value
eloc 30
dl 0
loc 38
ccs 10
cts 21
cp 0.4762
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A BuilderHtmlReport.__init__() 0 9 1
A BuilderHtmlReport.save_report_and_open() 0 16 2
1 1
import lxml.html
2 1
from lxml import etree
3 1
from lxml.builder import ElementMaker, E
4 1
import re
5 1
import os
6 1
import json
7 1
import webbrowser
8
9
10 1
class BuilderHtmlReport():
11
12 1
    def __init__(self, display_html, xml_parser, arf_file_src):
13
        self.display_html = display_html
14
        self.arf_file_src = arf_file_src
15
        self.src_xsl = xml_parser.get_src("xsl/xccdf-report.xsl")
16
        self.xslt_doc = etree.parse(self.src_xsl)
17
        self.xslt_transformer = etree.XSLT(self.xslt_doc)
18
19
        self.source_doc = etree.parse(self.arf_file_src)
20
        self.output_doc = self.xslt_transformer(self.source_doc)
21
22 1
    def save_report_and_open(self, save_src):
23
        tree = lxml.html.fromstring(str(self.output_doc))
24
25
        with open(save_src, 'w+') as f:
26
            f.writelines(etree.tostring(
27
                tree,
28
                xml_declaration=True,
29
                doctype=('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"'
30
                         ' "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'),
31
                encoding='utf-8',
32
                standalone=False,
33
                with_tail=False,
34
                method='html',
35
                pretty_print=True).decode('utf-8')
36
            )
37
        return [save_src]
38