26 lines
672 B
Python
26 lines
672 B
Python
|
import json
|
||
|
from tokopedia_logger import logger
|
||
|
|
||
|
class Config():
|
||
|
config = None
|
||
|
|
||
|
def __new__(cls, *args, **kw):
|
||
|
if not hasattr(cls, '_instance'):
|
||
|
orig = super(Config, cls)
|
||
|
cls._instance = orig.__new__(cls, *args, **kw)
|
||
|
return cls._instance
|
||
|
|
||
|
def __init__(self):
|
||
|
if not self.config:
|
||
|
try:
|
||
|
logger.info("Loading config fine...")
|
||
|
with open("conf.json", "r") as jsonfile:
|
||
|
self.config = json.load(jsonfile)
|
||
|
logger.info("Config file loaded.")
|
||
|
except Exception as e:
|
||
|
logger.error("Cannot load config file. Please check. Exiting......")
|
||
|
exit(1)
|
||
|
|
||
|
def get(self):
|
||
|
return self.config
|