Show More
@@ -23,19 +23,23 b' from .. import (' | |||
|
23 | 23 | pycompat, |
|
24 | 24 | ) |
|
25 | 25 | |
|
26 | def pprint(o): | |
|
26 | def pprint(o, bprefix=True): | |
|
27 | 27 | """Pretty print an object.""" |
|
28 | 28 | if isinstance(o, bytes): |
|
29 | return "b'%s'" % escapestr(o) | |
|
29 | if bprefix: | |
|
30 | return "b'%s'" % escapestr(o) | |
|
31 | return "'%s'" % escapestr(o) | |
|
30 | 32 | elif isinstance(o, bytearray): |
|
31 | 33 | # codecs.escape_encode() can't handle bytearray, so escapestr fails |
|
32 | 34 | # without coercion. |
|
33 | 35 | return "bytearray['%s']" % escapestr(bytes(o)) |
|
34 | 36 | elif isinstance(o, list): |
|
35 | return '[%s]' % (b', '.join(pprint(a) for a in o)) | |
|
37 | return '[%s]' % (b', '.join(pprint(a, bprefix=bprefix) for a in o)) | |
|
36 | 38 | elif isinstance(o, dict): |
|
37 | 39 | return '{%s}' % (b', '.join( |
|
38 | '%s: %s' % (pprint(k), pprint(v)) for k, v in sorted(o.items()))) | |
|
40 | '%s: %s' % (pprint(k, bprefix=bprefix), | |
|
41 | pprint(v, bprefix=bprefix)) | |
|
42 | for k, v in sorted(o.items()))) | |
|
39 | 43 | elif isinstance(o, bool): |
|
40 | 44 | return b'True' if o else b'False' |
|
41 | 45 | elif isinstance(o, int): |
General Comments 0
You need to be logged in to leave comments.
Login now