1
|
1 |
|
from ..oval_tree.builder import Builder |
2
|
1 |
|
from ..oval_tree.converter import Converter |
3
|
1 |
|
from .client_html_output import ClientHtmlOutput |
4
|
1 |
|
from .client_json_input import ClientJsonInput |
5
|
|
|
|
6
|
1 |
|
START_OF_FILE_NAME = 'graph-of-' |
7
|
|
|
|
8
|
|
|
|
9
|
1 |
|
class JsonToHtml(ClientHtmlOutput, ClientJsonInput): |
10
|
1 |
|
def __init__(self, args): |
11
|
1 |
|
super().__init__(args) |
12
|
1 |
|
self.hide_passing_tests = self.arg.hide_passing_tests |
13
|
1 |
|
self.oval_tree = None |
14
|
|
|
|
15
|
1 |
|
def get_only_fail_rule(self, rules): |
16
|
|
|
""" |
17
|
|
|
Function processes array of matched IDs of rules in selected file. |
18
|
|
|
Function retunes array of failed matched IDs of rules in selected file. |
19
|
|
|
""" |
20
|
1 |
|
raise NotImplementedError |
21
|
|
|
|
22
|
1 |
|
def _get_rows_of_unselected_rules(self): |
23
|
|
|
""" |
24
|
|
|
Function retunes array of rows where is not selected IDs of rules in selected file. |
25
|
|
|
""" |
26
|
|
|
raise NotImplementedError |
27
|
|
|
|
28
|
1 |
|
def _get_message(self): |
29
|
1 |
|
return { |
30
|
|
|
'command_name': 'json-to-graph', |
31
|
|
|
'description': 'Client for visualization of JSON created by command arf-to-json', |
32
|
|
|
'source_filename': 'JSON file', |
33
|
|
|
} |
34
|
|
|
|
35
|
1 |
|
def load_json_to_oval_tree(self, rule): |
36
|
1 |
|
dict_of_tree = self.json_data_file[rule] |
37
|
1 |
|
try: |
38
|
1 |
|
return Builder.dict_to_oval_tree(dict_of_tree) |
39
|
1 |
|
except Exception as error: |
40
|
1 |
|
raise ValueError('Data is not valid for OVAL tree.') from error |
41
|
|
|
|
42
|
1 |
|
def create_dict_of_rule(self, rule): |
43
|
1 |
|
self.oval_tree = self.load_json_to_oval_tree(rule) |
44
|
1 |
|
converter = Converter(self.oval_tree) |
45
|
1 |
|
return converter.to_js_tree_dict(self.hide_passing_tests) |
46
|
|
|
|
47
|
1 |
|
@staticmethod |
48
|
|
|
def _get_rule_id(rule): |
49
|
1 |
|
return rule.replace(START_OF_FILE_NAME, '') |
50
|
|
|
|
51
|
1 |
|
def _put_to_dict_oval_trees(self, dict_oval_trees, rule): |
52
|
1 |
|
dict_oval_trees[self._get_rule_id(rule)] = self.create_dict_of_rule(rule) |
53
|
|
|
|
54
|
1 |
|
def _get_src_for_one_graph(self, rule): |
55
|
1 |
|
return self.get_save_src(self._get_rule_id(rule)) |
56
|
|
|
|
57
|
1 |
|
def prepare_parser(self, parser): |
58
|
1 |
|
super().prepare_parser(parser) |
59
|
|
|
self.prepare_args_when_output_is_html(parser) |
60
|
|
|
|