mirror of
https://github.com/netbox-community/netbox-docker.git
synced 2025-08-09 00:04:46 +02:00
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:
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)
|
Reference in New Issue
Block a user