mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-10-02 01:20:47 +09:00
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>
This commit is contained in:
parent
9b044f7e3d
commit
3c47e4105e
@ -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)))
|
||||
|
Loading…
Reference in New Issue
Block a user