From bd557468d380695879ce272e01972756f811a1f0 Mon Sep 17 00:00:00 2001 From: ljf Date: Thu, 2 Sep 2021 02:28:51 +0200 Subject: [PATCH] [enh] read_yaml support stream --- moulinette/utils/filesystem.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/moulinette/utils/filesystem.py b/moulinette/utils/filesystem.py index 4844dd1f..9b1456d9 100644 --- a/moulinette/utils/filesystem.py +++ b/moulinette/utils/filesystem.py @@ -67,16 +67,17 @@ def read_json(file_path): return loaded_json -def read_yaml(file_path): +def read_yaml(file_): """ Safely read a yaml file Keyword argument: - file_path -- Path to the yaml file + file -- Path or stream to the yaml 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: