mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-14 19:27:06 +00:00
proxyclient: utils.py: allow to specify print function to chexdump
Signed-off-by: Sven Peter <sven@svenpeter.dev>
This commit is contained in:
parent
0a4d2ca222
commit
6445cf61ba
1 changed files with 3 additions and 3 deletions
|
@ -29,17 +29,17 @@ def _ascii(s):
|
|||
s2 += chr(c)
|
||||
return s2
|
||||
|
||||
def chexdump(s, st=0, abbreviate=True, indent=""):
|
||||
def chexdump(s, st=0, abbreviate=True, indent="", print_fn=print):
|
||||
last = None
|
||||
skip = False
|
||||
for i in range(0,len(s),16):
|
||||
val = s[i:i+16]
|
||||
if val == last and abbreviate:
|
||||
if not skip:
|
||||
print(indent+"%08x *" % (i + st))
|
||||
print_fn(indent+"%08x *" % (i + st))
|
||||
skip = True
|
||||
else:
|
||||
print(indent+"%08x %s %s |%s|" % (
|
||||
print_fn(indent+"%08x %s %s |%s|" % (
|
||||
i + st,
|
||||
hexdump(val[:8], ' ').ljust(23),
|
||||
hexdump(val[8:], ' ').ljust(23),
|
||||
|
|
Loading…
Reference in a new issue