| Total Complexity | 9 |
| Total Lines | 41 |
| 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 retunes 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 retunes 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') as file_: |
|
| 29 | 1 | try: |
|
| 30 | 1 | return json.load(file_) |
|
| 31 | 1 | except json.JSONDecodeError as error: |
|
| 32 | 1 | raise ValueError( |
|
| 33 | 'Used file "{}" is not valid json.'.format( |
||
| 34 | self.source_filename)) from error |
||
| 35 | |||
| 36 | 1 | def search_rules_id(self): |
|
| 37 | 1 | rules = self._get_wanted_rules(self.json_data_file.keys()) |
|
| 38 | 1 | if not rules: |
|
| 39 | 1 | raise ValueError('404 rule "{}" not found!'.format(self.rule_name)) |
|
| 40 | return rules |
||
| 41 |