Add function to load YAML files
This commit starts to remove some code redundancy from the startup scripts for easier maintenance.
This commit is contained in:
parent
3717b7469a
commit
50ade7bce1
30 changed files with 669 additions and 811 deletions
startup_scripts/startup_script_utils
1
startup_scripts/startup_script_utils/__init__.py
Normal file
1
startup_scripts/startup_script_utils/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
from .load_yaml import load_yaml
|
10
startup_scripts/startup_script_utils/load_yaml.py
Normal file
10
startup_scripts/startup_script_utils/load_yaml.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
from ruamel.yaml import YAML
|
||||
from pathlib import Path
|
||||
|
||||
def load_yaml(yaml_file: str):
|
||||
yf = Path(yaml_file)
|
||||
if not yf.is_file():
|
||||
return None
|
||||
with yf.open("r") as stream:
|
||||
yaml = YAML(typ="safe")
|
||||
return yaml.load(stream)
|
Loading…
Add table
Add a link
Reference in a new issue