[python] fix a few of the python tools to be python 2 and 3 compatible

This commit is contained in:
Travis Geiselbrecht
2020-02-20 01:22:31 -08:00
parent b54f5f2b0f
commit e0cdfbae17
3 changed files with 10 additions and 10 deletions

View File

@@ -3,8 +3,8 @@
import sys, os, struct
if len(sys.argv) < 2:
print "not enough args, usage:"
print "%s <binfile>" % sys.argv[0]
print ("not enough args, usage:")
print ("%s <binfile>" % sys.argv[0])
sys.exit(1)
f = open(sys.argv[1], "r+b")

View File

@@ -5,8 +5,8 @@
import sys, os, array
if len(sys.argv) < 3:
print "not enough args, usage:"
print "%s <binfile> <outfile>" % sys.argv[0]
print ("not enough args, usage:")
print ("%s <binfile> <outfile>" % sys.argv[0])
sys.exit(1)
fin = open(sys.argv[1], "r+b")

View File

@@ -13,18 +13,18 @@ parser.add_option("-a", "--after", dest="after", action="append",
if options.before and len(options.before) > 0:
for b in options.before:
print b
print (b)
offset = 0
f = bytearray(sys.stdin.read())
f = bytearray(sys.stdin.read(), 'utf-8')
for c in f:
if offset != 0 and offset % 16 == 0:
print ""
print "%#04x," % c,
print ("")
sys.stdout.write("%#04x," % c)
offset = offset + 1
print ""
print ("")
if options.after and len(options.after) > 0:
for a in options.after:
print a
print (a)