oval_graph.command_line_client.client_json_input   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 91.3%

Importance

Changes 0
Metric Value
wmc 9
eloc 25
dl 0
loc 40
rs 10
c 0
b 0
f 0
ccs 21
cts 23
cp 0.913

6 Methods

Rating   Name   Duplication   Size   Complexity  
A ClientJsonInput.__init__() 0 3 1
A ClientJsonInput.load_file() 0 2 1
A ClientJsonInput.get_only_fail_rule() 0 6 1
A ClientJsonInput._get_rows_of_unselected_rules() 0 5 1
A ClientJsonInput.search_rules_id() 0 5 2
A ClientJsonInput.get_json_data_file() 0 7 3
1 1
import json
2
3 1
from .client import Client
4
5
6 1
class ClientJsonInput(Client):
7 1
    def __init__(self, args):
8 1
        super().__init__(args)
9 1
        self.json_data_file = None
10
11 1
    def load_file(self):
12 1
        self.json_data_file = self.get_json_data_file()
13
14 1
    def get_only_fail_rule(self, rules):
15
        """
16
        Function processes array of matched IDs of rules in selected file.
17
        Function returns array of failed matched IDs of rules in selected file.
18
        """
19
        raise NotImplementedError
20
21 1
    def _get_rows_of_unselected_rules(self):
22
        """
23
        Function returns array of rows where is not selected IDs of rules in selected file.
24
        """
25
        raise NotImplementedError
26
27 1
    def get_json_data_file(self):
28 1
        with open(self.source_filename, 'r', encoding="utf-8") as file_:
29 1
            try:
30 1
                return json.load(file_)
31 1
            except json.JSONDecodeError as error:
32 1
                raise ValueError(
33
                    f'Used file "{self.source_filename}" is not valid json.') from error
34
35 1
    def search_rules_id(self):
36 1
        rules = self._get_wanted_rules(self.json_data_file.keys())
37 1
        if not rules:
38 1
            raise ValueError(f'404 rule "{self.rule_name}" not found!')
39
        return rules
40