15 Jul
2014
15 Jul
'14
5:30 p.m.
try:
addrfmt = CONF.get("hexdump_addrfmt", "developer")
except Exception:
addrfmt = "decimal"
if addrfmt == None:
addrfmt = "decimal"
elif (addrfmt != "decimal" and addrfmt != "hex" and addrfmt != "both"):
print "Invalid hexdump_addrfmt value %s. Using decimal." % addrfmt
addrfmt = "decimal"
for i in range(0, (len(data)/line_sz)):
out += "%03i: " % (i * line_sz)
if addrfmt == "hex":
out += "x%04X: " % (i * line_sz)
elif addrfmt == "both":
out += "%04i x%04X: " % ((i * line_sz), (i * line_sz))
else:
out += "%04i: " % (i * line_sz)
Just a thought...
Instead of having them choose from a few different symbolic choices, why not just let them specify the format themselves? So in the config:
hexdump_addrfmt = %0000x
and in the code:
fmt = CONF.get("hexdump_addrfmt", "developer") . . . thing = fmt % addr
I can just see someone coming along and wanting octal or something and if we just let them specify the format, we can avoid adding new symbols. What do you think?
--Dan