-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.py
30 lines (23 loc) · 855 Bytes
/
config.py
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
import json
from loguru import logger
class Config:
_KAFKA_CONFIG_PATH: str = "config/kafka.json"
_ENV_CONFIG_PATH: str = "config/env.json"
_AWS_CONFIG_PATH: str = "config/aws.json"
def __init__(self, type: str, path: str = None):
configFiles = {
"env": Config._ENV_CONFIG_PATH,
"kafka": Config._KAFKA_CONFIG_PATH,
"aws": Config._AWS_CONFIG_PATH,
}
self.path = path
if self.path is None:
self.path = configFiles[type]
if type not in configFiles.keys():
logger.error('Type of config has to either be "env" or "kafka" ')
if self.path is None:
self.path = configFiles[type]
with open(self.path, "rb") as f:
self.config = json.load(f)
def get(self, key: str):
return self.config[key]