Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Datalogger UI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Scientific Computing and Engineering Group
LippunerAG
WABEsense
Datalogger UI
Commits
7f03f93c
Commit
7f03f93c
authored
2 years ago
by
JuanPi Carbajal
Browse files
Options
Downloads
Patches
Plain Diff
feat: utils module
parent
5110ab92
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dataloggerui/utils.py
+31
-0
31 additions, 0 deletions
dataloggerui/utils.py
with
31 additions
and
0 deletions
dataloggerui/utils.py
0 → 100644
+
31
−
0
View file @
7f03f93c
from
pathlib
import
Path
from
typing
import
Union
import
yaml
def
yaml_load
(
file_path
:
Union
[
str
,
Path
],
*
,
ignore_private
:
bool
=
True
)
->
dict
:
"""
Load YAMl file, ignoring private fields (prefix:
"
__
"
).
Parameters
----------
file_path:
Path to YAML file.
ignore_private:
Flag to disable loading of private fields in the YAML file.
Returns
-------
data:
A dict containing the loaded key-value pairs from the YAML file.
"""
with
open
(
file_path
,
encoding
=
"
utf8
"
)
as
file
:
# The FullLoader parameter handles the conversion from YAML
# scalar values to Python the dictionary format
data
=
yaml
.
load
(
file
,
Loader
=
yaml
.
FullLoader
)
if
ignore_private
:
# erase private fields (starts with __)
for
k
in
tuple
(
k_
for
k_
in
data
.
keys
()
if
str
(
k_
).
startswith
(
"
__
"
)):
data
.
pop
(
k
)
return
data
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment