scripts: Remove python23compat.py
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>
This commit is contained in:
parent
9ad4399b0e
commit
6a62e0cb0d
|
@ -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:]
|
||||
|
|
|
@ -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__':
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue