Passed
Pull Request — master (#160)
by Jan
03:42
created

oval_graph.command_line_client.client_json_input   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 25
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A ClientJsonInput.__init__() 0 3 1
A ClientJsonInput.get_json_data_file() 0 8 3
A ClientJsonInput.search_rules_id() 0 5 1
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 = self.get_json_data_file()
10
11 1
    def get_json_data_file(self):
12 1
        with open(self.source_filename, 'r') as f:
13 1
            try:
14 1
                return json.load(f)
15 1
            except Exception as error:
16 1
                raise ValueError(
17
                    'Used file "{}" is not valid json.'.format(
18
                        self.source_filename))
19
20 1
    def search_rules_id(self):
21 1
        rules = self._get_wanted_rules_from_array_of_IDs(
22
            self.json_data_file.keys())
23 1
        notselected_rules = []
24
        return self._check_rules_id(rules, notselected_rules)
25