From 0764241e780c2c38099549d4a34794bc24f5d459 Mon Sep 17 00:00:00 2001 From: Superintendent <67196752+superintendent2521@users.noreply.github.com> Date: Sun, 10 Dec 2023 21:12:54 -0500 Subject: [PATCH 1/2] Make it see if theres a template bridgedata Add a check to see if template bridge data exists, and if it does, it will say please set variables and rename --- load_env_vars.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/load_env_vars.py b/load_env_vars.py index 47e82731..e2a64adb 100644 --- a/load_env_vars.py +++ b/load_env_vars.py @@ -8,14 +8,21 @@ load_dotenv() -def load_env_vars() -> None: # FIXME: there is a dynamic way to do this +def load_env_vars() -> None: """Load the environment variables from the config file.""" yaml = YAML() + config_file = "bridgeData.yaml" + template_file = "bridgeData_template.yaml" - if not pathlib.Path("bridgeData.yaml").exists(): - raise FileNotFoundError("bridgeData.yaml not found") + if not pathlib.Path(config_file).exists(): + if pathlib.Path(template_file).exists(): + raise FileNotFoundError( + f"{template_file} found. Please set variables and rename it to {config_file}." + ) + else: + raise FileNotFoundError(f"{config_file} not found") - with open("bridgeData.yaml", encoding="utf-8") as f: + with open(config_file, encoding="utf-8") as f: config = yaml.load(f) if "cache_home" in config: From 578ec7ebf8dbf8c16cb7fdc676f15bf818ed08df Mon Sep 17 00:00:00 2001 From: RhysyPiece360 <67196752+RhysyPiece360@users.noreply.github.com> Date: Mon, 11 Dec 2023 19:11:20 -0500 Subject: [PATCH 2/2] Use pre-commit and not do what i did last time --- load_env_vars.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/load_env_vars.py b/load_env_vars.py index e2a64adb..6b82f024 100644 --- a/load_env_vars.py +++ b/load_env_vars.py @@ -8,7 +8,7 @@ load_dotenv() -def load_env_vars() -> None: +def load_env_vars() -> None: # FIXME: there is a dynamic way to do this """Load the environment variables from the config file.""" yaml = YAML() config_file = "bridgeData.yaml" @@ -16,11 +16,8 @@ def load_env_vars() -> None: if not pathlib.Path(config_file).exists(): if pathlib.Path(template_file).exists(): - raise FileNotFoundError( - f"{template_file} found. Please set variables and rename it to {config_file}." - ) - else: - raise FileNotFoundError(f"{config_file} not found") + raise FileNotFoundError(f"{template_file} found. Please set variables and rename it to {config_file}.") + raise FileNotFoundError(f"{config_file} not found") with open(config_file, encoding="utf-8") as f: config = yaml.load(f)