Total Complexity | 7 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | 1 | import uuid |
|
2 | |||
3 | 1 | from .oval_node import OvalNode |
|
4 | |||
5 | # rework this (use static metodes) |
||
6 | |||
7 | |||
8 | 1 | class _BuilderOvalGraph: |
|
9 | 1 | def __init__(self): |
|
10 | 1 | pass |
|
11 | |||
12 | 1 | def _definition_dict_to_node(self, dict_of_definition): |
|
13 | 1 | children = [] |
|
14 | 1 | for child in dict_of_definition['node']: |
|
15 | 1 | if 'operator' in child and 'id': |
|
16 | 1 | children.append(self._definition_dict_to_node(child)) |
|
17 | else: |
||
18 | 1 | children.append( |
|
19 | OvalNode( |
||
20 | node_id=child['value_id'], |
||
21 | node_type='value', |
||
22 | value=child['value'], |
||
23 | negation=child['negate'], |
||
24 | comment=child['comment'], |
||
25 | tag=child['tag'], |
||
26 | test_result_details=child['test_result_details'], |
||
27 | )) |
||
28 | |||
29 | 1 | if 'id' in dict_of_definition: |
|
30 | 1 | children[0].node_id = dict_of_definition['id'] |
|
31 | 1 | return children[0] |
|
32 | else: |
||
33 | 1 | return OvalNode( |
|
34 | node_id=str(uuid.uuid4()), |
||
35 | node_type='operator', |
||
36 | value=dict_of_definition['operator'], |
||
37 | negation=dict_of_definition['negate'], |
||
38 | comment=dict_of_definition['comment'], |
||
39 | tag=dict_of_definition['tag'], |
||
40 | children=children, |
||
41 | ) |
||
42 | |||
43 | 1 | def get_oval_graph_from_dict_of_rule(self, rule): |
|
44 | 1 | dict_of_definition = rule['definition'] |
|
45 | 1 | return OvalNode( |
|
46 | node_id=rule['rule_id'], |
||
47 | node_type='operator', |
||
48 | value='and', |
||
49 | negation=False, |
||
50 | comment=dict_of_definition['comment'], |
||
51 | tag="Rule", |
||
52 | children=[self._definition_dict_to_node(dict_of_definition)], |
||
53 | ) |
||
54 |