eric7/DebugClients/Python/DebugVariables.py

branch
eric7
changeset 8573
77845f40ebfe
parent 8568
890dfe038613
child 8881
54e42bc2437a
equal deleted inserted replaced
8572:718f80d8bcde 8573:77845f40ebfe
267 @type any 267 @type any
268 @yield tuple containing the batch start index and a list 268 @yield tuple containing the batch start index and a list
269 containing the variable attributes 269 containing the variable attributes
270 @ytype tuple of (int, list) 270 @ytype tuple of (int, list)
271 """ 271 """
272 return super().getVariableList(list(var)) 272 yield from super().getVariableList(list(var))
273 273
274 274
275 ############################################################ 275 ############################################################
276 ## Resolver for Sets and Frozensets 276 ## Resolver for Sets and Frozensets
277 ############################################################ 277 ############################################################
428 428
429 # in case it has additional fields 429 # in case it has additional fields
430 d = super().getVariableList(var) 430 d = super().getVariableList(var)
431 431
432 if var.size > 1024 * 1024: 432 if var.size > 1024 * 1024:
433 d.append(('min', 433 d.append(
434 'ndarray too big, calculating min would slow down debugging')) 434 ('min',
435 d.append(('max', 435 'ndarray too big, calculating min would slow down debugging')
436 'ndarray too big, calculating max would slow down debugging')) 436 )
437 d.append(('mean', 437 d.append(
438 'ndarray too big, calculating mean would slow down debugging')) 438 ('max',
439 'ndarray too big, calculating max would slow down debugging')
440 )
441 d.append(
442 ('mean',
443 'ndarray too big, calculating mean would slow down debugging')
444 )
439 elif self.__isNumeric(var): 445 elif self.__isNumeric(var):
440 if var.size == 0: 446 if var.size == 0:
441 d.append(('min', 'empty array')) 447 d.append(('min', 'empty array'))
442 d.append(('max', 'empty array')) 448 d.append(('max', 'empty array'))
443 d.append(('mean', 'empty array')) 449 d.append(('mean', 'empty array'))
648 """ 654 """
649 d = [] 655 d = []
650 attributes = () 656 attributes = ()
651 # Gently handle exception which could occure as special 657 # Gently handle exception which could occure as special
652 # cases, e.g. already deleted C++ objects, str conversion.. 658 # cases, e.g. already deleted C++ objects, str conversion..
653 try: 659 with contextlib.suppress(Exception):
654 qttype = type(var).__name__ 660 qttype = type(var).__name__
655 661
656 if qttype in ('QLabel', 'QPushButton'): 662 if qttype in ('QLabel', 'QPushButton'):
657 attributes = ('text', ) 663 attributes = ('text', )
658 elif qttype == 'QByteArray': 664 elif qttype == 'QByteArray':
659 d.append(('bytes', bytes(var))) 665 d.append(('bytes', bytes(var)))
660 d.append(('hex', "QByteArray", "{0}".format(var.toHex()))) 666 d.append(('hex', "QByteArray", "{0}".format(var.toHex())))
661 d.append(('base64', "QByteArray", 667 d.append(
662 "{0}".format(var.toBase64()))) 668 ('base64', "QByteArray",
663 d.append(('percent encoding', "QByteArray", 669 "{0}".format(var.toBase64()))
664 "{0}".format(var.toPercentEncoding()))) 670 )
671 d.append(
672 ('percent encoding', "QByteArray",
673 "{0}".format(var.toPercentEncoding()))
674 )
665 elif qttype in ('QPoint', 'QPointF'): 675 elif qttype in ('QPoint', 'QPointF'):
666 attributes = ('x', 'y') 676 attributes = ('x', 'y')
667 elif qttype in ('QRect', 'QRectF'): 677 elif qttype in ('QRect', 'QRectF'):
668 attributes = ('x', 'y', 'width', 'height') 678 attributes = ('x', 'y', 'width', 'height')
669 elif qttype in ('QSize', 'QSizeF'): 679 elif qttype in ('QSize', 'QSizeF'):
679 ('hsva', "{0:d}, {1:d}, {2:d}, {3:d}".format(h, s, v, a)) 689 ('hsva', "{0:d}, {1:d}, {2:d}, {3:d}".format(h, s, v, a))
680 ) 690 )
681 c, m, y, k, a = var.getCmyk() 691 c, m, y, k, a = var.getCmyk()
682 d.append( 692 d.append(
683 ('cmyka', 693 ('cmyka',
684 "{0:d}, {1:d}, {2:d}, {3:d}, {4:d}".format(c, m, y, k, a)) 694 "{0:d}, {1:d}, {2:d}, {3:d}, {4:d}".format(c, m, y, k, a))
685 ) 695 )
686 elif qttype in ('QDate', 'QTime', 'QDateTime'): 696 elif qttype in ('QDate', 'QTime', 'QDateTime'):
687 d.append((qttype[1:].lower(), var.toString())) 697 d.append((qttype[1:].lower(), var.toString()))
688 elif qttype == 'QDir': 698 elif qttype == 'QDir':
689 attributes = ('path', 'absolutePath', 'canonicalPath') 699 attributes = ('path', 'absolutePath', 'canonicalPath')
731 741
732 # PySide specific 742 # PySide specific
733 elif qttype == 'EnumType': # Not in PyQt possible 743 elif qttype == 'EnumType': # Not in PyQt possible
734 for key, value in var.values.items(): 744 for key, value in var.values.items():
735 d.append((key, int(value))) 745 d.append((key, int(value)))
736 except Exception:
737 pass
738 746
739 for attribute in attributes: 747 for attribute in attributes:
740 d.append((attribute, getattr(var, attribute)())) 748 d.append((attribute, getattr(var, attribute)()))
741 749
742 # add additional fields 750 # add additional fields

eric ide

mercurial