src/eric7/DebugClients/Python/DebugVariables.py

branch
eric7
changeset 10332
7308cfc6e558
parent 10180
3a595df36c9a
child 10373
093dcebe5ecb
equal deleted inserted replaced
10331:c1a2ff7e3575 10332:7308cfc6e558
10 import contextlib 10 import contextlib
11 import sys 11 import sys
12 12
13 from collections.abc import ItemsView, KeysView, ValuesView 13 from collections.abc import ItemsView, KeysView, ValuesView
14 14
15 from DebugConfig import BatchSize, ConfigKnownQtTypes, ConfigQtNames 15 from DebugConfig import (
16 BatchSize,
17 ConfigKnownQtTypes,
18 ConfigQtNames,
19 UnknownAttributeValueMarker,
20 )
16 21
17 # 22 #
18 # This code was inspired by pydevd. 23 # This code was inspired by pydevd.
19 # 24 #
20 25
50 @return list containing the variable attributes 55 @return list containing the variable attributes
51 @rtype list 56 @rtype list
52 """ 57 """
53 d = [] 58 d = []
54 for name in dir(var): 59 for name in dir(var):
55 with contextlib.suppress(AttributeError): 60 try:
56 attribute = getattr(var, name) 61 attribute = getattr(var, name)
57 d.append((name, attribute)) 62 d.append((name, attribute))
63 except AttributeError:
64 # ignore non-existent attributes
65 pass
66 except Exception as exc:
67 # The attribute value cannot be determined/is not available yet.
68 d.append((name, "{0}{1}".format(UnknownAttributeValueMarker, str(exc))))
58 69
59 return d 70 return d
60 71
61 72
62 ############################################################ 73 ############################################################
77 @type any 88 @type any
78 @yield tuple containing the batch start index and a list 89 @yield tuple containing the batch start index and a list
79 containing the variable attributes 90 containing the variable attributes
80 @ytype tuple of (int, list) 91 @ytype tuple of (int, list)
81 """ 92 """
82 d = [] 93 d = super().getVariableList(var)
83 for name in dir(var):
84 with contextlib.suppress(AttributeError):
85 attribute = getattr(var, name)
86 d.append((name, attribute))
87 94
88 yield -1, d 95 yield -1, d
89 while True: 96 while True:
90 yield -2, [] 97 yield -2, []
91 98

eric ide

mercurial