import environ
from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent.parent

env = environ.Env()

READ_DOT_ENV_FILE = env.bool("DJANGO_READ_DOT_ENV_FILE", default=True)
if READ_DOT_ENV_FILE:
    # OS environment variables take precedence over variables from .env
    env.read_env(str(BASE_DIR / ".env"))

# Access the "ENV_NAME" environment variable using env
env_name = env("ENV_NAME")

if env_name == 'Production':
    from .production import * # noqa
elif env_name == 'Staging':
    from .staging import * # noqa
elif env_name == 'Development':
    from .development import * # noqa
else:
    raise ValueError("Invalid or missing ENV_NAME environment variable")
