summaryrefslogtreecommitdiff
path: root/tools/binman/comp_util.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-01-09 20:14:04 -0700
committerSimon Glass <sjg@chromium.org>2022-01-25 12:36:11 -0700
commit0d1e95aa18b0f8db292a4ade73846192d835a7ce (patch)
tree10a7479b1381d11dc8293ac2f34abdb4fd4d249b /tools/binman/comp_util.py
parentad35ce5466187298bc998e851f355f4bb119428b (diff)
binman: Tidy up pylint warnings in comp_util
Tweak some naming and comments to resolve these. Use WriteFile() to write the file. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/comp_util.py')
-rw-r--r--tools/binman/comp_util.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/tools/binman/comp_util.py b/tools/binman/comp_util.py
index 541e1919dd6..7e741cb62cc 100644
--- a/tools/binman/comp_util.py
+++ b/tools/binman/comp_util.py
@@ -8,7 +8,7 @@ import tempfile
from patman import tools
-def Compress(indata, algo, with_header=True):
+def compress(indata, algo, with_header=True):
"""Compress some data using a given algorithm
Note that for lzma this uses an old version of the algorithm, not that
@@ -21,11 +21,11 @@ def Compress(indata, algo, with_header=True):
called from multiple threads.
Args:
- indata: Input data to compress
- algo: Algorithm to use ('none', 'gzip', 'lz4' or 'lzma')
+ indata (bytes): Input data to compress
+ algo (str): Algorithm to use ('none', 'gzip', 'lz4' or 'lzma')
Returns:
- Compressed data
+ bytes: Compressed data
"""
if algo == 'none':
return indata
@@ -51,7 +51,7 @@ def Compress(indata, algo, with_header=True):
data = hdr + data
return data
-def Decompress(indata, algo, with_header=True):
+def decompress(indata, algo, with_header=True):
"""Decompress some data using a given algorithm
Note that for lzma this uses an old version of the algorithm, not that
@@ -61,11 +61,11 @@ def Decompress(indata, algo, with_header=True):
directory to be previously set up, by calling PrepareOutputDir().
Args:
- indata: Input data to decompress
- algo: Algorithm to use ('none', 'gzip', 'lz4' or 'lzma')
+ indata (bytes): Input data to decompress
+ algo (str): Algorithm to use ('none', 'gzip', 'lz4' or 'lzma')
Returns:
- Compressed data
+ (bytes) Compressed data
"""
if algo == 'none':
return indata
@@ -73,8 +73,7 @@ def Decompress(indata, algo, with_header=True):
data_len = struct.unpack('<I', indata[:4])[0]
indata = indata[4:4 + data_len]
fname = tools.GetOutputFilename('%s.decomp.tmp' % algo)
- with open(fname, 'wb') as fd:
- fd.write(indata)
+ tools.WriteFile(fname, indata)
if algo == 'lz4':
data = tools.Run('lz4', '-dc', fname, binary=True)
elif algo == 'lzma':