2023-09-07 18:29:53 +03:00

30 lines
903 B
Python

from utils.libs.decouple import config, UndefinedValueError
from utils.utils import str_to_bool
from utils.logger import logger
def set_conf_value(key):
try:
value = config(key)
if value == '':
logger.warn(f'WARNING: The variable {key} is an empty string.')
return value
except (UndefinedValueError):
logger.warn(f'WARNING: Please set the variable {key} in the .env file based on .env.example.')
return None
class App:
Port=set_conf_value('APP_PORT') or 5000
class Mongo:
Username=set_conf_value('MONGO_USER')
Password=set_conf_value('MONGO_PASS')
Host=set_conf_value('MONGO_HOST')
Port=set_conf_value('MONGO_PORT')
Database=set_conf_value('MONGO_DB') or 'git'
Collection=set_conf_value('MONGO_COLLECTION') or 'repos'
class Parser:
MinStars=set_conf_value('STARS_MIN')
MaxStars=set_conf_value('STARS_MAX')
GithubToken=set_conf_value('GITHUB_TOKEN')