It's simpler to use b"" designations around binary strings than to use the as_bytes() function.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- scripts/buildrom.py | 6 ++---- scripts/checkrom.py | 4 +--- scripts/python23compat.py | 14 -------------- 3 files changed, 3 insertions(+), 21 deletions(-) delete mode 100644 scripts/python23compat.py
diff --git a/scripts/buildrom.py b/scripts/buildrom.py index 0499049..48bfc17 100755 --- a/scripts/buildrom.py +++ b/scripts/buildrom.py @@ -7,8 +7,6 @@
import sys, struct
-from python23compat import as_bytes - def alignpos(pos, alignbytes): mask = alignbytes - 1 return (pos + mask) & ~mask @@ -31,7 +29,7 @@ def main(): count = len(data)
# Pad to a 512 byte boundary - data += as_bytes("\0") * (alignpos(count, 512) - count) + data += b"\0" * (alignpos(count, 512) - count) count = len(data)
# Check if a pci header is present @@ -42,7 +40,7 @@ def main():
# Fill in size field; clear checksum field blocks = struct.pack('<B', int(count/512)) - data = data[:2] + blocks + data[3:6] + as_bytes("\0") + data[7:] + data = data[:2] + blocks + data[3:6] + b"\0" + data[7:]
# Checksum rom data = data[:6] + checksum(data) + data[7:] diff --git a/scripts/checkrom.py b/scripts/checkrom.py index aced5e2..a5b15a4 100755 --- a/scripts/checkrom.py +++ b/scripts/checkrom.py @@ -8,8 +8,6 @@ import sys, struct import layoutrom, buildrom
-from python23compat import as_bytes - def subst(data, offset, new): return data[:offset] + new + data[offset + len(new):]
@@ -88,7 +86,7 @@ def main():
# Write final file f = open(outfile, 'wb') - f.write((as_bytes("\0") * (finalsize - datasize)) + rawdata) + f.write((b"\0" * (finalsize - datasize)) + rawdata) f.close()
if __name__ == '__main__': diff --git a/scripts/python23compat.py b/scripts/python23compat.py deleted file mode 100644 index 572b7f1..0000000 --- a/scripts/python23compat.py +++ /dev/null @@ -1,14 +0,0 @@ -# Helper code for compatibility of the code with both Python 2 and Python 3 -# -# Copyright (C) 2014 Johannes Krampf johannes.krampf@googlemail.com -# -# This file may be distributed under the terms of the GNU GPLv3 license. - -import sys - -if (sys.version_info > (3, 0)): - def as_bytes(str): - return bytes(str, "ASCII") -else: - def as_bytes(str): - return str