Fix bool evaluation bugs

This commit is contained in:
Santiago Lo Coco 2024-12-09 16:23:21 +01:00
parent 7beee91d33
commit 706e616830
2 changed files with 8 additions and 2 deletions

View File

@ -2,6 +2,8 @@ import os
from dotenv import load_dotenv from dotenv import load_dotenv
from utils import evaluate_bool
load_dotenv() load_dotenv()
DATABASE_URI = os.getenv("DATABASE") DATABASE_URI = os.getenv("DATABASE")
@ -9,6 +11,6 @@ SERVICE_NAME = os.getenv("SERVICE_NAME")
SERVICE_TYPE = os.getenv("SERVICE_TYPE") SERVICE_TYPE = os.getenv("SERVICE_TYPE")
SERVICE_IP = os.getenv("SERVICE_IP") SERVICE_IP = os.getenv("SERVICE_IP")
SERVICE_PORT = os.getenv("SERVICE_PORT") SERVICE_PORT = os.getenv("SERVICE_PORT")
DEFAULT_ENDPOINTS = os.getenv("DEFAULT_ENDPOINTS") DEFAULT_ENDPOINTS = evaluate_bool(os.getenv("DEFAULT_ENDPOINTS", "false"))
LOG_LEVEL = os.getenv("LOG_LEVEL") LOG_LEVEL = os.getenv("LOG_LEVEL")
RECREATE_DB = os.getenv("RECREATE_DB") RECREATE_DB = evaluate_bool(os.getenv("RECREATE_DB", "false"))

View File

@ -13,3 +13,7 @@ def is_valid_url(url):
re.IGNORECASE, re.IGNORECASE,
) )
return re.match(url_regex, url) is not None return re.match(url_regex, url) is not None
def evaluate_bool(var):
return var.lower() in ("yes", "y", "true", "1")