Passed
Push — master ( 361725...fcee18 )
by Daniel
02:49
created

BasicNeeds.fn_load_configuration()   A

Complexity

Conditions 2

Size

Total Lines 5
Code Lines 5

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nop 1
dl 5
loc 5
rs 10
c 0
b 0
f 0
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:
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
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