Passed
Pull Request — master (#149)
by Jan
03:34
created

oval_graph.arf_to_html_report   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 29.4%

Importance

Changes 0
Metric Value
eloc 60
dl 0
loc 66
ccs 10
cts 34
cp 0.294
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A ArfToHtmlReport.__init__() 0 14 2
A ArfToHtmlReport._get_message() 0 7 1
A ArfToHtmlReport.prepare_parser() 0 24 1
A ArfToHtmlReport.prepare_data() 0 9 1
1 1
import argparse
2 1
import uuid
3 1
from .client import Client
4 1
from .xml_parser import XmlParser
5 1
from ._builder_html_report import BuilderHtmlReport
6
7
8 1
class ArfToHtmlReport(Client):
9 1
    def __init__(self, args):
10
        self.parser = None
11
        self.MESSAGES = self._get_message()
12
        self.arg = self.parse_arguments(args)
13
        self.source_filename = self.arg.source_filename
14
        self.out = self.arg.output
15
        self.display_html = True if self.out is None else self.arg.display
16
        self.verbose = self.arg.verbose
17
        self.xml_parser = XmlParser(self.source_filename)
18
        self.rule_name = '.'
19
        self.isatty = False
20
        self.show_failed_rules = False
21
        self.all_in_one = True
22
        self.START_OF_FILE_NAME = 'report-'
23
24 1
    def _get_message(self):
25
        MESSAGES = {
26
            'description': 'Client for genretate of SCAP report from ARF file.',
27
            '--output': 'The directory where to save output directory with files.',
28
            'source_filename': 'ARF scan file',
29
        }
30
        return MESSAGES
31
32 1
    def prepare_data(self, rules):
33
        builder = BuilderHtmlReport(
34
            self.display_html,
35
            self.xml_parser,
36
            self.source_filename)
37
        out_src = builder.save_report_and_open(
38
            self.get_save_src(str(uuid.uuid4())))
39
        self.open_html(out_src)
40
        return out_src
41
42 1
    def prepare_parser(self):
43
        self.parser = argparse.ArgumentParser(
44
            description=self.MESSAGES.get('description'))
45
        self.parser.add_argument(
46
            '-v',
47
            '--verbose',
48
            action="store_true",
49
            default=False,
50
            help="Displays details about the results of the running command.")
51
        self.parser.add_argument(
52
            '-d',
53
            '--display',
54
            action="store_true",
55
            default=False,
56
            help="Enables opening a web browser with a graph, when is used --output.")
57
        self.parser.add_argument(
58
            '-o',
59
            '--output',
60
            action="store",
61
            default=None,
62
            help=self.MESSAGES.get('--output'))
63
        self.parser.add_argument(
64
            "source_filename",
65
            help=self.MESSAGES.get('source_filename'))
66