aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-05-17 22:00:44 -0600
committerSimon Glass <sjg@chromium.org>2019-07-10 16:52:58 -0600
commit3c47e4105e0b467938660a986c261f2db10a2edd (patch)
tree72c4a7818ee21e558d419dbc48891edf995ca036 /tools
parent9b044f7e3d1b085499877774557b2db47fb4339c (diff)
downloadu-boot-3c47e4105e0b467938660a986c261f2db10a2edd.zip
u-boot-3c47e4105e0b467938660a986c261f2db10a2edd.tar.gz
u-boot-3c47e4105e0b467938660a986c261f2db10a2edd.tar.bz2
patman: Allow reading files in text mode
While reading files in binary mode is the norm, sometimes we want to use text mode. Add an optional parameter to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/patman/tools.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index bdc1953..8e9f22a 100644
--- a/tools/patman/tools.py
+++ b/tools/patman/tools.py
@@ -214,7 +214,7 @@ def Filename(fname):
# If not found, just return the standard, unchanged path
return fname
-def ReadFile(fname):
+def ReadFile(fname, binary=True):
"""Read and return the contents of a file.
Args:
@@ -223,7 +223,7 @@ def ReadFile(fname):
Returns:
data read from file, as a string.
"""
- with open(Filename(fname), 'rb') as fd:
+ with open(Filename(fname), binary and 'rb' or 'r') as fd:
data = fd.read()
#self._out.Info("Read file '%s' size %d (%#0x)" %
#(fname, len(data), len(data)))