Commit 5e0cb781 authored by 崔为之's avatar 崔为之 💪🏽

Update project

parent 6db708d5
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
# @Description : # @Description :
""" """
from typing import Optional
from application.constants import DEFAULT_CONFIG, ENV_CONFIG_MAP
class FileHelper: class FileHelper:
""" """
...@@ -19,20 +23,15 @@ class FileHelper: ...@@ -19,20 +23,15 @@ class FileHelper:
""" """
@classmethod @classmethod
def get_filename(cls, env: str) -> str: def get_filename(cls, env: Optional[str]) -> str:
""" """
Get the configuration file name based on the environment. Get the configuration file name based on the environment.
:param env: a string representing the environment. :param env: a string representing the environment.
It should be 'PRODUCTION' or None. It should be one of the keys in ENV_CONFIG_MAP, or None.
:return: a string representing the configuration file name. :return: a string representing the configuration file name.
If env is 'PRODUCTION', return 'production_config.yaml'.
Otherwise, return 'config.yaml'.
""" """
if env == 'PRODUCTION': return ENV_CONFIG_MAP.get(env, DEFAULT_CONFIG)
return f'{env.lower()}_config.yaml'
else:
return 'config.yaml'
def __repr__(self): def __repr__(self):
""" """
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
# @Version : Python 3.11.4
# @Software : Sublime Text 4
# @Author : StudentCWZ
# @Email : StudentCWZ@outlook.com
# @Date : 2023/11/4 15:08
# @File : __init__.py.py
# @Description :
"""
from .constants import DEFAULT_CONFIG, ENV_CONFIG_MAP
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
# @Version : Python 3.11.4
# @Software : Sublime Text 4
# @Author : StudentCWZ
# @Email : StudentCWZ@outlook.com
# @Date : 2023/11/4 15:08
# @File : constants.py
# @Description :
"""
DEFAULT_CONFIG = 'config.yaml'
ENV_CONFIG_MAP = {
'PRODUCTION': 'production_config.yaml',
'DEVELOPMENT': 'config.yaml',
# Add more environments here if necessary
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment