Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
崔为之
elp
Commits
5e0cb781
Commit
5e0cb781
authored
Nov 04, 2023
by
崔为之
💪🏽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update project
parent
6db708d5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
8 deletions
+39
-8
application/common/file.py
application/common/file.py
+7
-8
application/constants/__init__.py
application/constants/__init__.py
+13
-0
application/constants/constants.py
application/constants/constants.py
+19
-0
No files found.
application/common/file.py
View file @
5e0cb781
...
...
@@ -10,6 +10,10 @@
# @Description :
"""
from
typing
import
Optional
from
application.constants
import
DEFAULT_CONFIG
,
ENV_CONFIG_MAP
class
FileHelper
:
"""
...
...
@@ -19,20 +23,15 @@ class FileHelper:
"""
@
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.
: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.
If env is 'PRODUCTION', return 'production_config.yaml'.
Otherwise, return 'config.yaml'.
"""
if
env
==
'PRODUCTION'
:
return
f
'
{
env
.
lower
()
}
_config.yaml'
else
:
return
'config.yaml'
return
ENV_CONFIG_MAP
.
get
(
env
,
DEFAULT_CONFIG
)
def
__repr__
(
self
):
"""
...
...
application/constants/__init__.py
0 → 100644
View file @
5e0cb781
#!/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
application/constants/constants.py
0 → 100644
View file @
5e0cb781
#!/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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment