From 2f59023eee886d69ed7413db7ac4991b4caf8477 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 23 Sep 2021 20:55:35 +0200 Subject: [PATCH] read_file: support for custom file mode --- moulinette/utils/filesystem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moulinette/utils/filesystem.py b/moulinette/utils/filesystem.py index d075b83d..e14c9059 100644 --- a/moulinette/utils/filesystem.py +++ b/moulinette/utils/filesystem.py @@ -15,7 +15,7 @@ from moulinette.core import MoulinetteError # Files & directories -------------------------------------------------- -def read_file(file_path): +def read_file(file_path, file_mode="r"): """ Read a regular text file @@ -35,7 +35,7 @@ def read_file(file_path): # Open file and read content try: - with open(file_path, "r") as f: + with open(file_path, file_mode) as f: file_content = f.read() except IOError as e: raise MoulinetteError("cannot_open_file", file=file_path, error=str(e))