-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
29 lines (24 loc) · 703 Bytes
/
config.py
File metadata and controls
29 lines (24 loc) · 703 Bytes
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
import os
from dotenv import dotenv_values
import json
class Config:
__conf = {
**os.environ
}
@staticmethod
def get(name):
return Config.__conf[name]
@staticmethod
def set(name, value):
Config.__conf[name] = value
@staticmethod
def parse_env_file(file_path):
Config.__conf = {
**dotenv_values(file_path),
**os.environ
}
# Parse JSON and set None if variable does not exist
if 'active_page_groups' in Config.__conf:
Config.__conf['active_page_groups'] = json.loads(Config.__conf['active_page_groups'])
else:
Config.__conf['active_page_groups'] = None