summaryrefslogtreecommitdiff
path: root/tools/patman/tools.py
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-07-23 15:56:06 -0400
committerTom Rini <trini@konsulko.com>2020-07-23 15:56:06 -0400
commit5d3a21df6694ebd66d5c34c9d62a26edc7456fc7 (patch)
tree5de77f2861f6856866c5bf4ffa7cab22d371ccf3 /tools/patman/tools.py
parent56d37f1c564107e27d873181d838571b7d7860e7 (diff)
parent60e7fa8b3b8538aae1e644dac61d5e4076901edb (diff)
Merge tag 'dm-pull-20jul20' of git://git.denx.de/u-boot-dm
binman support for FIT new UCLASS_SOC patman switch 'test' command minor fdt fixes patman usability improvements
Diffstat (limited to 'tools/patman/tools.py')
-rw-r--r--tools/patman/tools.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index b50370dfe8d..d41115a22c4 100644
--- a/tools/patman/tools.py
+++ b/tools/patman/tools.py
@@ -114,14 +114,16 @@ def SetInputDirs(dirname):
indir = dirname
tout.Debug("Using input directories %s" % indir)
-def GetInputFilename(fname):
+def GetInputFilename(fname, allow_missing=False):
"""Return a filename for use as input.
Args:
fname: Filename to use for new file
+ allow_missing: True if the filename can be missing
Returns:
- The full path of the filename, within the input directory
+ The full path of the filename, within the input directory, or
+ None on error
"""
if not indir or fname[:1] == '/':
return fname
@@ -130,6 +132,8 @@ def GetInputFilename(fname):
if os.path.exists(pathname):
return pathname
+ if allow_missing:
+ return None
raise ValueError("Filename '%s' not found in input path (%s) (cwd='%s')" %
(fname, ','.join(indir), os.getcwd()))
@@ -270,7 +274,7 @@ def ReadFile(fname, binary=True):
#(fname, len(data), len(data)))
return data
-def WriteFile(fname, data):
+def WriteFile(fname, data, binary=True):
"""Write data into a file.
Args:
@@ -279,7 +283,7 @@ def WriteFile(fname, data):
"""
#self._out.Info("Write file '%s' size %d (%#0x)" %
#(fname, len(data), len(data)))
- with open(Filename(fname), 'wb') as fd:
+ with open(Filename(fname), binary and 'wb' or 'w') as fd:
fd.write(data)
def GetBytes(byte, size):