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
4b6bdfaa
Commit
4b6bdfaa
authored
Nov 04, 2023
by
崔为之
💪🏽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update project
parent
53d881b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
application/libs/config/local.py
application/libs/config/local.py
+15
-0
No files found.
application/libs/config/local.py
View file @
4b6bdfaa
...
@@ -18,12 +18,27 @@ import yaml
...
@@ -18,12 +18,27 @@ import yaml
class
LocalConfig
:
class
LocalConfig
:
def
__init__
(
self
,
config_dir
:
str
):
def
__init__
(
self
,
config_dir
:
str
):
"""
Initialize a LocalConfig instance.
:param config_dir: The directory where the config files are located.
"""
self
.
config_dir
=
config_dir
self
.
config_dir
=
config_dir
def
load
(
self
,
filename
:
str
)
->
Any
:
def
load
(
self
,
filename
:
str
)
->
Any
:
"""
Load a config file and return its content.
:param filename: The name of the config file to load.
:return: The content of the config file.
:raises FileNotFoundError: If the file does not exist.
"""
# Construct the full path of the config file
filepath
=
os
.
path
.
join
(
self
.
config_dir
,
filename
)
filepath
=
os
.
path
.
join
(
self
.
config_dir
,
filename
)
# Check if the file exists
if
not
os
.
path
.
exists
(
filepath
):
if
not
os
.
path
.
exists
(
filepath
):
raise
FileNotFoundError
(
f
'No such file or directory:
{
filepath
}
'
)
raise
FileNotFoundError
(
f
'No such file or directory:
{
filepath
}
'
)
# Open the file and load its content
with
open
(
filepath
,
'r'
)
as
file
:
with
open
(
filepath
,
'r'
)
as
file
:
cfg
=
yaml
.
safe_load
(
file
)
cfg
=
yaml
.
safe_load
(
file
)
return
cfg
return
cfg
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