Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 652daa6

Browse files
committed
Minor bug fix and layout adjustments
1 parent 758a858 commit 652daa6

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

extra/dbgtool/dbgtool.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@ def convert(inputFile):
3333
fileSize = fileStat.st_size
3434

3535
if fileSize > 65280:
36-
print 'ERROR: the provided input file \'%s\' is too big for debug.exe' % inputFile
36+
print "ERROR: the provided input file '%s' is too big for debug.exe" % inputFile
3737
sys.exit(1)
3838

39-
script = 'n %s\r\nr cx\r\n' % os.path.basename(inputFile.replace('.', '_'))
40-
script += "%x\r\nf 0100 ffff 00\r\n" % fileSize
39+
script = "n %s\nr cx\n" % os.path.basename(inputFile.replace(".", "_"))
40+
script += "%x\nf 0100 ffff 00\n" % fileSize
4141
scrString = ""
4242
counter = 256
4343
counter2 = 0
4444

45-
fp = open(inputFile, 'rb')
45+
fp = open(inputFile, "rb")
4646
fileContent = fp.read()
4747

4848
for fileChar in fileContent:
49-
unsignedFileChar = struct.unpack('B', fileChar)[0]
49+
unsignedFileChar = struct.unpack("B", fileChar)[0]
5050

5151
if unsignedFileChar != 0:
5252
counter2 += 1
@@ -56,49 +56,49 @@ def convert(inputFile):
5656
else:
5757
scrString += " %02x" % unsignedFileChar
5858
elif scrString:
59-
script += "%s\r\n" % scrString
59+
script += "%s\n" % scrString
6060
scrString = ""
6161
counter2 = 0
6262

6363
counter += 1
6464

6565
if counter2 == 20:
66-
script += "%s\r\n" % scrString
66+
script += "%s\n" % scrString
6767
scrString = ""
6868
counter2 = 0
6969

70-
script += "w\r\nq\r\n"
70+
script += "w\nq\n"
7171

7272
return script
7373

7474
def main(inputFile, outputFile):
7575
if not os.path.isfile(inputFile):
76-
print 'ERROR: the provided input file \'%s\' is not a regular file' % inputFile
76+
print "ERROR: the provided input file '%s' is not a regular file" % inputFile
7777
sys.exit(1)
7878

7979
script = convert(inputFile)
8080

8181
if outputFile:
82-
fpOut = open(outputFile, 'w')
82+
fpOut = open(outputFile, "w")
8383
sys.stdout = fpOut
8484
sys.stdout.write(script)
8585
sys.stdout.close()
8686
else:
8787
print script
8888

89-
if __name__ == '__main__':
90-
usage = '%s -i <input file> [-o <output file>]' % sys.argv[0]
91-
parser = OptionParser(usage=usage, version='0.1')
89+
if __name__ == "__main__":
90+
usage = "%s -i <input file> [-o <output file>]" % sys.argv[0]
91+
parser = OptionParser(usage=usage, version="0.1")
9292

9393
try:
94-
parser.add_option('-i', dest='inputFile', help='Input binary file')
94+
parser.add_option("-i", dest="inputFile", help="Input binary file")
9595

96-
parser.add_option('-o', dest='outputFile', help='Output debug.exe text file')
96+
parser.add_option("-o", dest="outputFile", help="Output debug.exe text file")
9797

9898
(args, _) = parser.parse_args()
9999

100100
if not args.inputFile:
101-
parser.error('Missing the input file, -h for help')
101+
parser.error("Missing the input file, -h for help")
102102

103103
except (OptionError, TypeError), e:
104104
parser.error(e)

0 commit comments

Comments
 (0)