From f45e4df652811ed25242c83807d67063417446f9 Mon Sep 17 00:00:00 2001 From: hploetz Date: Fri, 24 Nov 2006 22:50:17 +0000 Subject: make it possible to print an arbitrary offset git-svn-id: svn+ssh://localhost/home/henryk/svn/cyberflex-shell/trunk@144 f711b948-2313-0410-aaa9-d29f33439f0b --- utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'utils.py') diff --git a/utils.py b/utils.py index e9cc38b..582da63 100644 --- a/utils.py +++ b/utils.py @@ -37,7 +37,7 @@ def parse_binary(value, bytemasks, verbose = False, value_len = 8): return result _myprintable = " " + string.letters + string.digits + string.punctuation -def hexdump(data, indent = 0, short = False, linelen = 16): +def hexdump(data, indent = 0, short = False, linelen = 16, offset = 0): r"""Generates a nice hexdump of data and returns it. Consecutive lines will be indented with indent spaces. When short is true, will instead generate hexdump without adresses and on one line. @@ -63,7 +63,7 @@ def hexdump(data, indent = 0, short = False, linelen = 16): while len(head) > 0: if pos > 0: result = result + "\n%s" % (' ' * indent) - result = result + FORMATSTRING % (pos, hexable(head), printable(head)) + result = result + FORMATSTRING % (pos+offset, hexable(head), printable(head)) pos = pos + len(head) (head, tail) = (tail[:linelen], tail[linelen:]) return result -- cgit v1.2.3