-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfiguration.py
More file actions
36 lines (29 loc) · 1.04 KB
/
configuration.py
File metadata and controls
36 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from typing import Dict, Any, Optional
# Defining a dictionay which can store key and value of any data-type
config: Dict[Any, Any] = dict()
def init_config(args) -> bool:
global config
for key, value in args.__dict__.items():
config[key] = value
else:
return True
def set_config(key: str, value: str, overrite: bool) -> bool:
global config
if key in config.keys():
if overrite is False:
print(f"Overrite is set to False, and value of {key} is already configured")
return False
print(f"Previous value for {key} was {config[key]}, Now replacing with new value {value}")
else:
print(f"No value found for {key}, Inserting new value {value}")
config[key] = value
return True
# This function can return string or None
def get_config(key: str) -> Optional[str]:
global config
if key in config.keys():
rtn_value: str = config[key]
print(f"get_config is called, value for {key} is {rtn_value}")
return rtn_value
else:
return None