forked from tpd94/CDRM-Project
		
	Refactor config file checks to improve path handling and add module docstring
This commit is contained in:
		
							parent
							
								
									29be40ab95
								
							
						
					
					
						commit
						c82e493ef1
					
				@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user