25 |
25 |
26 import DebugClientCapabilities |
26 import DebugClientCapabilities |
27 import DebugVariables |
27 import DebugVariables |
28 from DebugBase import setRecursionLimit, printerr # __IGNORE_WARNING__ |
28 from DebugBase import setRecursionLimit, printerr # __IGNORE_WARNING__ |
29 from AsyncFile import AsyncFile, AsyncPendingWrite |
29 from AsyncFile import AsyncFile, AsyncPendingWrite |
30 from DebugConfig import ConfigQtNames, ConfigVarTypeStrings |
30 from DebugConfig import ConfigQtNames, SpecialAttributes |
31 from FlexCompleter import Completer |
31 from FlexCompleter import Completer |
32 from DebugUtilities import prepareJsonCommand |
32 from DebugUtilities import prepareJsonCommand |
33 from BreakpointWatch import Breakpoint, Watch |
33 from BreakpointWatch import Breakpoint, Watch |
34 |
34 |
35 from DebugUtilities import getargvalues, formatargvalues |
35 from DebugUtilities import getargvalues, formatargvalues |
1712 @param scope 1 to filter using the globals filter, 0 using the locals |
1712 @param scope 1 to filter using the globals filter, 0 using the locals |
1713 filter. |
1713 filter. |
1714 Variables are only added to the list, if their name do not match |
1714 Variables are only added to the list, if their name do not match |
1715 any of the filter expressions. |
1715 any of the filter expressions. |
1716 @type int |
1716 @type int |
1717 @param filterList the indices of variable types to be filtered. |
1717 @param filterList list of variable types to be filtered. |
1718 Variables are only added to the list, if their type is not |
1718 Variables are only added to the list, if their type is not |
1719 contained in the filter list. |
1719 contained in the filter list. |
1720 @type list of int |
1720 @type list of str |
1721 @return A tuple consisting of a list of formatted variables. Each |
1721 @return A tuple consisting of a list of formatted variables. Each |
1722 variable entry is a tuple of three elements, the variable name, |
1722 variable entry is a tuple of three elements, the variable name, |
1723 its type and value. |
1723 its type and value. |
1724 @rtype list of tuple of (str, str, str) |
1724 @rtype list of tuple of (str, str, str) |
1725 """ |
1725 """ |
1746 break |
1746 break |
1747 if matched: |
1747 if matched: |
1748 continue |
1748 continue |
1749 |
1749 |
1750 # filter hidden attributes (filter #0) |
1750 # filter hidden attributes (filter #0) |
1751 if 0 in filterList and str(key)[:2] == '__': |
1751 if '__' in filterList and str(key)[:2] == '__': |
1752 continue |
1752 continue |
1753 |
1753 |
1754 # special handling for '__builtins__' (it's way too big) |
1754 # special handling for '__builtins__' (it's way too big) |
1755 if key == '__builtins__': |
1755 if key == '__builtins__': |
1756 rvalue = '<module builtins (built-in)>' |
1756 rvalue = '<module builtins (built-in)>' |
1757 valtype = 'module' |
1757 valtype = 'module' |
1758 if ConfigVarTypeStrings.index(valtype) in filterList: |
1758 if valtype in filterList: |
1759 continue |
1759 continue |
|
1760 elif ( |
|
1761 key in SpecialAttributes and |
|
1762 "special_attributes" in filterList |
|
1763 ): |
|
1764 continue |
|
1765 elif ( |
|
1766 key == "__hash__" and |
|
1767 "builtin_function_or_method" in filterList |
|
1768 ): |
|
1769 continue |
1760 else: |
1770 else: |
1761 isQt = False |
1771 isQt = False |
1762 # valtypestr, e.g. class 'PyQt5.QtCore.QPoint' |
1772 # valtypestr, e.g. class 'PyQt5.QtCore.QPoint' |
1763 valtypestr = str(type(value))[1:-1] |
1773 valtypestr = str(type(value))[1:-1] |
1764 _, valtype = valtypestr.split(' ', 1) |
1774 _, valtype = valtypestr.split(' ', 1) |
1765 # valtype, e.g. PyQt5.QtCore.QPoint |
1775 # valtype, e.g. PyQt5.QtCore.QPoint |
1766 valtype = valtype[1:-1] |
1776 valtype = valtype[1:-1] |
1767 # Strip 'instance' to be equal with Python 3 |
1777 # Strip 'instance' to be equal with Python 3 |
1768 if valtype == "instancemethod": |
1778 if valtype == "instancemethod": |
1769 valtype = "method" |
1779 valtype = "method" |
1770 elif valtype == "type" or valtype == "classobj": |
1780 elif valtype in ("type", "classobj"): |
1771 valtype = "class" |
1781 valtype = "class" |
|
1782 elif valtype == "method-wrapper": |
|
1783 valtype = "builtin_function_or_method" |
1772 |
1784 |
1773 # valtypename, e.g. QPoint |
1785 # valtypename, e.g. QPoint |
1774 valtypename = type(value).__name__ |
1786 valtypename = type(value).__name__ |
1775 try: |
1787 if valtype in filterList: |
1776 if ConfigVarTypeStrings.index(valtype) in filterList: |
1788 continue |
1777 continue |
1789 elif ( |
1778 except ValueError: |
1790 valtype in ("sip.enumtype", "sip.wrappertype") and |
1779 if valtype in ("sip.enumtype", "sip.wrappertype"): |
1791 'class' in filterList |
1780 if ConfigVarTypeStrings.index('class') in filterList: |
1792 ): |
1781 continue |
1793 continue |
1782 elif (valtype == "sip.methoddescriptor" or |
1794 elif ( |
1783 valtype == "method_descriptor"): |
1795 valtype in ( |
1784 if ConfigVarTypeStrings.index('method') in filterList: |
1796 "sip.methoddescriptor", "method_descriptor") and |
1785 continue |
1797 'method' in filterList |
1786 elif valtype in ("numpy.ndarray", "array.array"): |
1798 ): |
1787 if ConfigVarTypeStrings.index('list') in filterList: |
1799 continue |
1788 continue |
1800 elif ( |
1789 elif valtypename == "MultiValueDict": |
1801 valtype in ("numpy.ndarray", "array.array") and |
1790 if ConfigVarTypeStrings.index('dict') in filterList: |
1802 'list' in filterList |
1791 continue |
1803 ): |
1792 elif ConfigVarTypeStrings.index('instance') in filterList: |
1804 continue |
1793 continue |
1805 elif valtypename == "MultiValueDict" and 'dict' in filterList: |
1794 |
1806 continue |
1795 isQt = valtype.startswith(ConfigQtNames) |
1807 elif 'instance' in filterList: |
1796 if (not valtypestr.startswith('type ') and |
1808 continue |
1797 valtypename not in ("ndarray", "MultiValueDict", |
1809 |
1798 "array", "defaultdict") and |
1810 isQt = valtype.startswith(ConfigQtNames) |
1799 not isQt): |
1811 # TODO: see if this is still needed |
1800 valtype = valtypestr |
1812 # if (not valtypestr.startswith('type ') and |
|
1813 # valtypename not in ("ndarray", "MultiValueDict", |
|
1814 # "array", "defaultdict") and |
|
1815 # not isQt): |
|
1816 # valtype = valtypestr |
1801 |
1817 |
1802 try: |
1818 try: |
1803 if valtype in self.arrayTypes: |
1819 if valtype in self.arrayTypes: |
1804 rvalue = "{0:d}".format(len(value)) |
1820 rvalue = "{0:d}".format(len(value)) |
1805 elif valtype == 'array.array': |
1821 elif valtype == 'array.array': |