Passed
Pull Request — master (#160)
by Jan
05:53
created

oval_graph._builder_html_report   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 40
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A BuilderHtmlReport.__init__() 0 9 1
A BuilderHtmlReport._get_html_object() 0 3 1
A BuilderHtmlReport._get_html() 0 12 1
A BuilderHtmlReport.save_report() 0 4 2
1 1
from io import BytesIO
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
3 1
import lxml.html
4 1
from lxml import etree
5
6
7 1
class BuilderHtmlReport():
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
8
9 1
    def __init__(self, display_html, xml_parser, arf_file_src):
10 1
        self.display_html = display_html
11 1
        self.arf_file_src = arf_file_src
12 1
        self.src_xsl = xml_parser.get_src("schemas/xsl/xccdf-report.xsl")
13 1
        self.xslt_doc = etree.parse(self.src_xsl)
14 1
        self.xslt_transformer = etree.XSLT(self.xslt_doc)
15
16 1
        self.source_doc = etree.parse(self.arf_file_src)
17 1
        self.output_doc = self.xslt_transformer(self.source_doc)
18
19 1
    def _get_html_object(self):
20 1
        html_object = lxml.html.fromstring(str(self.output_doc))
21 1
        return html_object
22
23 1
    def _get_html(self):
24 1
        html_object = self._get_html_object()
25 1
        result = etree.tostring(
26
            html_object,
27
            xml_declaration=True,
28
            doctype=('<!DOCTYPE html>'),
29
            encoding='utf-8',
30
            standalone=False,
31
            with_tail=False,
32
            method='html',
33
            pretty_print=True)
34 1
        return BytesIO(result)
35
36 1
    def save_report(self, save_src):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
37 1
        with open(save_src, 'wb+') as data_file:
38 1
            data_file.writelines(self._get_html())
39
        return [save_src]
40