MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / SafeRepr

Class SafeRepr

_pydevd_bundle/pydevd_safe_repr.py:12–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11
12class SafeRepr(object):
13 # Can be used to override the encoding from locale.getpreferredencoding()
14 locale_preferred_encoding = None
15
16 # Can be used to override the encoding used for sys.stdout.encoding
17 sys_stdout_encoding = None
18
19 # String types are truncated to maxstring_outer when at the outer-
20 # most level, and truncated to maxstring_inner characters inside
21 # collections.
22 maxstring_outer = 2**16
23 maxstring_inner = 128
24 string_types = (str, bytes)
25 bytes = bytes
26 set_info = (set, "{", "}", False)
27 frozenset_info = (frozenset, "frozenset({", "})", False)
28 int_types = (int,)
29 long_iter_types = (list, tuple, bytearray, range, dict, set, frozenset)
30
31 # Collection types are recursively iterated for each limit in
32 # maxcollection.
33 maxcollection = (60, 20)
34
35 # Specifies type, prefix string, suffix string, and whether to include a
36 # comma if there is only one element. (Using a sequence rather than a
37 # mapping because we use isinstance() to determine the matching type.)
38 collection_types = [
39 (tuple, "(", ")", True),
40 (list, "[", "]", False),
41 frozenset_info,
42 set_info,
43 ]
44 try:
45 from collections import deque
46
47 collection_types.append((deque, "deque([", "])", False))
48 except Exception:
49 pass
50
51 # type, prefix string, suffix string, item prefix string,
52 # item key/value separator, item suffix string
53 dict_types = [(dict, "{", "}", "", ": ", "")]
54 try:
55 from collections import OrderedDict
56
57 dict_types.append((OrderedDict, "OrderedDict([", "])", "(", ", ", ")"))
58 except Exception:
59 pass
60
61 # All other types are treated identically to strings, but using
62 # different limits.
63 maxother_outer = 2**16
64 maxother_inner = 128
65
66 convert_to_hex = False
67 raw_value = False
68
69 def __call__(self, obj):

Callers 7

key_to_strMethod · 0.90
get_var_dataMethod · 0.90
SafeReprTestBaseClass · 0.90
test_py3_str_slicingFunction · 0.90
test_raw_bytesFunction · 0.90
test_raw_unicodeFunction · 0.90
test_no_reprFunction · 0.90

Calls 1

appendMethod · 0.45

Tested by 4

test_py3_str_slicingFunction · 0.72
test_raw_bytesFunction · 0.72
test_raw_unicodeFunction · 0.72
test_no_reprFunction · 0.72