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

oval_graph._builder_html_report   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 34.78%

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 41
ccs 8
cts 23
cp 0.3478
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 13 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
        self.display_html = display_html
11
        self.arf_file_src = arf_file_src
12
        self.src_xsl = xml_parser.get_src("xsl/xccdf-report.xsl")
13
        self.xslt_doc = etree.parse(self.src_xsl)
0 ignored issues
show
introduced by
Module 'lxml.etree' has no 'parse' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects.
Loading history...
14
        self.xslt_transformer = etree.XSLT(self.xslt_doc)
0 ignored issues
show
introduced by
Module 'lxml.etree' has no 'XSLT' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects.
Loading history...
15
16
        self.source_doc = etree.parse(self.arf_file_src)
0 ignored issues
show
introduced by
Module 'lxml.etree' has no 'parse' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects.
Loading history...
17
        self.output_doc = self.xslt_transformer(self.source_doc)
18
19 1
    def _get_html_object(self):
20
        html_object = lxml.html.fromstring(str(self.output_doc))
21
        return html_object
22
23 1
    def _get_html(self):
24
        html_object = self._get_html_object()
25
        result = etree.tostring(
0 ignored issues
show
introduced by
Module 'lxml.etree' has no 'tostring' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects.
Loading history...
26
            html_object,
27
            xml_declaration=True,
28
            doctype=('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"'
29
                     ' "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'),
30
            encoding='utf-8',
31
            standalone=False,
32
            with_tail=False,
33
            method='html',
34
            pretty_print=True)
35
        return BytesIO(result)
36
37 1
    def save_report(self, save_src):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
38
        with open(save_src, 'wb+') as data_file:
39
            data_file.writelines(self._get_html())
40
        return [save_src]
41