def _format(data): for offset, hexa, s in strutils.hexdump(data): yield [ ("offset", offset + " "), ("text", hexa + " "), ("text", s) ]
def dump(self, data, hexdump): if hexdump: for line in strutils.hexdump(data): self("\t%s %s %s" % line) else: data = strutils.native( strutils.escape_control_characters( data.decode("ascii", "replace").replace(u"\ufffd", u"."))) for i in data.split("\n"): self("\t%s" % i)
def dump(self, data, hexdump): if hexdump: for line in strutils.hexdump(data): self("\t%s %s %s" % line) else: data = strutils.native( strutils.escape_control_characters( data .decode("ascii", "replace") .replace(u"\ufffd", u".") ) ) for i in data.split("\n"): self("\t%s" % i)
def test_hexdump(): assert list(strutils.hexdump(b"one\0" * 10))
def to_hex_lines(data): h = strutils.hexdump(data) lines = [] for o, h, s in h: lines.append('%s %s %s' % (o, h, s)) return lines