Total Complexity | 3 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 47.62% |
Changes | 0 |
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 |