32 lines
783 B
Python
32 lines
783 B
Python
from dotenv import load_dotenv
|
|
from os import getenv
|
|
|
|
|
|
load_dotenv()
|
|
|
|
|
|
def str2bool(v):
|
|
return v.lower() in ("yes", "true", "t", "1", "on")
|
|
|
|
|
|
class Config():
|
|
|
|
def __init__(self) -> None:
|
|
self.ESPN_S2 = getenv("ESPN_S2", 0)
|
|
self.LEAGUE_ID = int(getenv("LEAGUE_ID", 0))
|
|
self.SWID = getenv("SWID", 0)
|
|
self.FETCH_LEAGUE = str2bool(getenv("FETCH_LEAGUE", 0))
|
|
self.SPREADSHEET_ID = getenv("SPREADSHEET_ID", 0)
|
|
self.SHEET_NAME = getenv("WORKSHEET_NAME", 0)
|
|
self.check_values()
|
|
|
|
def check_values(self):
|
|
for attribute, value in self.__dict__.items():
|
|
if value == 0:
|
|
raise Exception("ERROR: Unproperly set environment variable {attribute}, please review".format(attribute=attribute))
|
|
|
|
|
|
try:
|
|
cfg = Config()
|
|
except Exception as e:
|
|
print(e) |