From c82e493ef1e5179f9285e40245de0017b7be8391 Mon Sep 17 00:00:00 2001 From: voldemort <5692900+yell0wsuit@users.noreply.github.com> Date: Wed, 23 Jul 2025 01:41:38 +0700 Subject: [PATCH] Refactor config file checks to improve path handling and add module docstring --- custom_functions/prechecks/config_file_checks.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/custom_functions/prechecks/config_file_checks.py b/custom_functions/prechecks/config_file_checks.py index a3f8c39..94952b6 100644 --- a/custom_functions/prechecks/config_file_checks.py +++ b/custom_functions/prechecks/config_file_checks.py @@ -1,11 +1,13 @@ +"""Module to check for the config file.""" + import os def check_for_config_file(): - if os.path.exists(f"{os.getcwd()}/configs/config.yaml"): + """Check for the config file.""" + if os.path.exists(os.path.join(os.getcwd(), "configs", "config.yaml")): return - else: - default_config = """\ + default_config = """ default_wv_cdm: '' default_pr_cdm: '' secret_key_flask: 'secretkey' @@ -22,6 +24,8 @@ remote_cdm_secret: '' # port: '' # database: '' """ - with open(f"{os.getcwd()}/configs/config.yaml", "w") as f: + with open( + os.path.join(os.getcwd(), "configs", "config.yaml"), "w", encoding="utf-8" + ) as f: f.write(default_config) return