mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
[enh] read_yaml support stream
This commit is contained in:
parent
882caf4786
commit
bd557468d3
1 changed files with 4 additions and 3 deletions
|
@ -67,16 +67,17 @@ def read_json(file_path):
|
||||||
return loaded_json
|
return loaded_json
|
||||||
|
|
||||||
|
|
||||||
def read_yaml(file_path):
|
def read_yaml(file_):
|
||||||
"""
|
"""
|
||||||
Safely read a yaml file
|
Safely read a yaml file
|
||||||
|
|
||||||
Keyword argument:
|
Keyword argument:
|
||||||
file_path -- Path to the yaml file
|
file -- Path or stream to the yaml file
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Read file
|
# Read file
|
||||||
file_content = read_file(file_path)
|
file_path = file_ if isinstance(file_, str) else file_.name
|
||||||
|
file_content = read_file(file_) if isinstance(file_, str) else file_
|
||||||
|
|
||||||
# Try to load yaml to check if it's syntaxically correct
|
# Try to load yaml to check if it's syntaxically correct
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue