From 91ae49d11a7ea26434fc169f724944f722ac3d37 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Wed, 25 Apr 2012 19:42:59 +0200 Subject: gui: Add support for ascii-hex Signed-off-by: Michael Buesch --- toprammer | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'toprammer') diff --git a/toprammer b/toprammer index 0c0563d..2c1c7f8 100755 --- a/toprammer +++ b/toprammer @@ -81,12 +81,12 @@ def usage(): print " auto Autodetect. (input only)" print " bin Raw binary data" print " ihex Intel hex" - print " hex Human readable hex" + print " ahex Hex with ASCII dump" IO_handlers = { "bin" : IO_binary, "ihex" : IO_ihex, - "hex" : IO_hex, + "ahex" : IO_ahex, } def fileOut(filename, format, data): @@ -97,23 +97,16 @@ def fileOut(filename, format, data): else: file(filename, "w+b").write(data) -def fileIn(filename, format): +def fileIn(filename, fmtString): if filename == "-": data = sys.stdin.read() else: data = file(filename, "rb").read() - if format == "auto": - if IO_ihex().autodetect(data): - format = "ihex" - elif IO_hex().autodetect(data): - format = "hex" - elif IO_binary().autodetect(data): - format = "bin" - else: - assert(0) - handler = IO_handlers[format]() - data = handler.toBinary(data) - return data + if fmtString == "auto": + handler = IO_autodetect(data)() + else: + handler = IO_handlers[fmtString]() + return handler.toBinary(data) def main(argv): opt_verbose = 1 -- cgit v1.2.3