| Total Complexity | 5 |
| Total Lines | 30 |
| Duplicated Lines | 56.67 % |
| Changes | 0 | ||
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | """ |
||
| 2 | BasicNeeds - useful functions library |
||
| 3 | |||
| 4 | This library has functions useful to keep main logic short and simple |
||
| 5 | """ |
||
| 6 | |||
| 7 | # standard Python packages |
||
| 8 | from datetime import datetime, timezone |
||
| 9 | import json |
||
| 10 | import os.path |
||
| 11 | |||
| 12 | |||
| 13 | View Code Duplication | class BasicNeeds: |
|
|
|
|||
| 14 | cfg_dtls = {} |
||
| 15 | |||
| 16 | def fn_load_configuration(self): |
||
| 17 | with open(os.path.dirname(__file__) + "/config.json", 'r') as json_file: |
||
| 18 | self.cfg_dtls = json.load(json_file) |
||
| 19 | self.cfg_dtls['data_types']['empty'] = '' |
||
| 20 | self.cfg_dtls['data_types']['str'] = '.' |
||
| 21 | |||
| 22 | def fn_optional_print(self, boolean_variable, string_to_print): |
||
| 23 | if boolean_variable: |
||
| 24 | self.fn_timestamped_print(self, string_to_print) |
||
| 25 | |||
| 26 | @staticmethod |
||
| 27 | def fn_timestamped_print(self, string_to_print): |
||
| 28 | print(datetime.now(timezone.utc).strftime("%Y-%b-%d %H:%M:%S.%f %Z") |
||
| 29 | + ' - ' + string_to_print) |
||
| 30 |