Refactor config file checks to improve path handling and add module docstring

This commit is contained in:
voldemort 2025-07-23 01:41:38 +07:00
parent 29be40ab95
commit c82e493ef1

View File

@ -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