summaryrefslogtreecommitdiffstats
path: root/toprammer
diff options
context:
space:
mode:
authorMichael Buesch <m@bues.ch>2012-04-25 19:42:59 +0200
committerMichael Buesch <m@bues.ch>2012-04-25 19:42:59 +0200
commit91ae49d11a7ea26434fc169f724944f722ac3d37 (patch)
tree2b78264ee8b594d95561d986be3d9b6dddb391de /toprammer
parentde8d5e492da55be806f1e2b0b0a07c6f16236a8f (diff)
downloadtoprammer-91ae49d11a7ea26434fc169f724944f722ac3d37.tar.xz
toprammer-91ae49d11a7ea26434fc169f724944f722ac3d37.zip
gui: Add support for ascii-hex
Signed-off-by: Michael Buesch <m@bues.ch>
Diffstat (limited to 'toprammer')
-rwxr-xr-xtoprammer23
1 files changed, 8 insertions, 15 deletions
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
bues.ch cgit interface