From 6445cf61baf3b437ca014b625363006f9c056c6e Mon Sep 17 00:00:00 2001 From: Sven Peter Date: Mon, 13 Dec 2021 16:31:49 +0100 Subject: [PATCH] proxyclient: utils.py: allow to specify print function to chexdump Signed-off-by: Sven Peter --- proxyclient/m1n1/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proxyclient/m1n1/utils.py b/proxyclient/m1n1/utils.py index aa163503..611c2917 100644 --- a/proxyclient/m1n1/utils.py +++ b/proxyclient/m1n1/utils.py @@ -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),