eric6/DebugClients/Python/DebugVariables.py

branch
Variables Viewer
changeset 6988
87ad87ef1910
parent 6978
720247f98e1f
child 7250
d8bdc55aee1a
equal deleted inserted replaced
6982:419c20ec6cd3 6988:87ad87ef1910
243 yield -1, d 243 yield -1, d
244 244
245 while True: 245 while True:
246 yield -2, {} 246 yield -2, {}
247 247
248
249 ############################################################
250 ## Resolver for dict_items, dict_keys and dict_values
251 ############################################################
252
253
254 class DictViewResolver(ListResolver):
255 """
256 Class used to resolve from dict views.
257 """
258 def resolve(self, var, attribute):
259 """
260 Public method to get an attribute from a variable.
261
262 @param var variable to extract an attribute or value from
263 @type tuple or list
264 @param attribute id of the value to extract
265 @type str
266 @return value of the attribute
267 @rtype any
268 """
269 return super(DictViewResolver, self).resolve(list(var), attribute)
270
271 def getDictionary(self, var):
272 """
273 Public method to get the attributes of a variable as a dictionary.
274
275 @param var variable to be converted
276 @type any
277 @return dictionary containing the variable attributes
278 @rtype dict
279 """
280 return super(DictViewResolver, self).getDictionary(list(var))
281
248 282
249 ############################################################ 283 ############################################################
250 ## Resolver for Sets and Frozensets 284 ## Resolver for Sets and Frozensets
251 ############################################################ 285 ############################################################
252 286
578 612
579 613
580 defaultResolver = DefaultResolver() 614 defaultResolver = DefaultResolver()
581 dictResolver = DictResolver() 615 dictResolver = DictResolver()
582 listResolver = ListResolver() 616 listResolver = ListResolver()
617 dictViewResolver = DictViewResolver()
583 setResolver = SetResolver() 618 setResolver = SetResolver()
584 ndarrayResolver = NdArrayResolver() 619 ndarrayResolver = NdArrayResolver()
585 multiValueDictResolver = MultiValueDictResolver() 620 multiValueDictResolver = MultiValueDictResolver()
586 arrayResolver = ArrayResolver() 621 arrayResolver = ArrayResolver()
587 622
613 ] 648 ]
614 649
615 try: 650 try:
616 _TypeMap.append((long, None)) # __IGNORE_WARNING__ 651 _TypeMap.append((long, None)) # __IGNORE_WARNING__
617 except Exception: 652 except Exception:
618 pass # not available on all python versions 653 pass # not available on all Python versions
619 654
620 try: 655 try:
621 _TypeMap.append((unicode, None)) # __IGNORE_WARNING__ 656 _TypeMap.append((unicode, None)) # __IGNORE_WARNING__
622 except Exception: 657 except Exception:
623 pass # not available on all python versions 658 pass # not available on all Python versions
624 659
625 try: 660 try:
626 import array 661 import array
627 _TypeMap.append((array.array, arrayResolver)) 662 _TypeMap.append((array.array, arrayResolver))
628 except ImportError: 663 except ImportError:
638 from django.utils.datastructures import MultiValueDict 673 from django.utils.datastructures import MultiValueDict
639 # it should go before dict 674 # it should go before dict
640 _TypeMap.insert(0, (MultiValueDict, multiValueDictResolver)) 675 _TypeMap.insert(0, (MultiValueDict, multiValueDictResolver))
641 except ImportError: 676 except ImportError:
642 pass # django may not be installed 677 pass # django may not be installed
678
679 try:
680 from collections.abc import ItemsView, KeysView, ValuesView
681 _TypeMap.append((ItemsView, dictViewResolver))
682 _TypeMap.append((KeysView, dictViewResolver))
683 _TypeMap.append((ValuesView, dictViewResolver))
684 except ImportError:
685 pass # not available on all Python versions
643 686
644 687
645 def getType(obj): 688 def getType(obj):
646 """ 689 """
647 Public method to get the type information for an object. 690 Public method to get the type information for an object.

eric ide

mercurial