Less characters to print (especially tabs and line breaks)
git-svn-id: svn+ssh://localhost/home/henryk/svn/cyberflex-shell/trunk@9 f711b948-2313-0410-aaa9-d29f33439f0b
This commit is contained in:
parent
4535fd115a
commit
ebeb989e38
3
utils.py
3
utils.py
|
@ -1,5 +1,6 @@
|
|||
import pycsc, string, binascii, sys
|
||||
|
||||
_myprintable = " " + string.letters + string.digits + string.punctuation
|
||||
def hexdump(data, indent = 0, short = False):
|
||||
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
|
||||
|
@ -14,7 +15,7 @@ def hexdump(data, indent = 0, short = False):
|
|||
return " ".join([binascii.b2a_hex(a) for a in data])
|
||||
|
||||
def printable(data):
|
||||
return "".join([e in string.printable and e or "." for e in data])
|
||||
return "".join([e in _myprintable and e or "." for e in data])
|
||||
|
||||
if short:
|
||||
return "%s (%s)" % (hexable(data), printable(data))
|
||||
|
|
Loading…
Reference in New Issue