Total Complexity | 9 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Coverage | 91.3% |
Changes | 0 |
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 |