135 |
135 |
136 <b>Note</b>: This class is meant to be subclassed by individual |
136 <b>Note</b>: This class is meant to be subclassed by individual |
137 DebugClient classes. Do not instantiate it directly. |
137 DebugClient classes. Do not instantiate it directly. |
138 """ |
138 """ |
139 clientCapabilities = DebugClientCapabilities.HasAll |
139 clientCapabilities = DebugClientCapabilities.HasAll |
|
140 |
|
141 # keep these in sync with VariablesViewer.VariableItem.Indicators |
|
142 Indicators = ("()", "[]", "{:}", "{}") # __IGNORE_WARNING__ |
140 |
143 |
141 def __init__(self): |
144 def __init__(self): |
142 """ |
145 """ |
143 Constructor |
146 Constructor |
144 """ |
147 """ |
1431 varlist = [] |
1434 varlist = [] |
1432 |
1435 |
1433 if scope != -1: |
1436 if scope != -1: |
1434 variable = dict |
1437 variable = dict |
1435 for attribute in var: |
1438 for attribute in var: |
1436 if attribute[-2:] in ["[]", "()", "{}"]: # __IGNORE_WARNING__ |
1439 attribute = self.__extractIndicators(attribute)[0] |
1437 attribute = attribute[:-2] |
|
1438 typeObject, typeName, typeStr, resolver = \ |
1440 typeObject, typeName, typeStr, resolver = \ |
1439 DebugVariables.getType(variable) |
1441 DebugVariables.getType(variable) |
1440 if resolver: |
1442 if resolver: |
1441 variable = resolver.resolve(variable, attribute) |
1443 variable = resolver.resolve(variable, attribute) |
1442 else: |
1444 else: |
1455 self.sendJsonCommand("ResponseVariable", { |
1457 self.sendJsonCommand("ResponseVariable", { |
1456 "scope": scope, |
1458 "scope": scope, |
1457 "variable": var, |
1459 "variable": var, |
1458 "variables": varlist, |
1460 "variables": varlist, |
1459 }) |
1461 }) |
|
1462 |
|
1463 def __extractIndicators(self, var): |
|
1464 """ |
|
1465 Private method to extract the indicator string from a variable text. |
|
1466 |
|
1467 @param var variable text |
|
1468 @type str |
|
1469 @return tuple containing the variable text without indicators and the |
|
1470 indicator string |
|
1471 @rtype tuple of two str |
|
1472 """ |
|
1473 for indicator in DebugClientBase.Indicators: |
|
1474 if var.endswith(indicator): |
|
1475 return var[:-len(indicator)], indicator |
|
1476 |
|
1477 return var, "" |
1460 |
1478 |
1461 def __formatQtVariable(self, value, qttype): |
1479 def __formatQtVariable(self, value, qttype): |
1462 """ |
1480 """ |
1463 Private method to produce a formatted output of a simple Qt4/Qt5 type. |
1481 Private method to produce a formatted output of a simple Qt4/Qt5 type. |
1464 |
1482 |
1638 break |
1656 break |
1639 if matched: |
1657 if matched: |
1640 continue |
1658 continue |
1641 |
1659 |
1642 # filter hidden attributes (filter #0) |
1660 # filter hidden attributes (filter #0) |
1643 if 0 in filter and str(key)[:2] == '__': |
1661 if 0 in filter and str(key)[:2] == '__' and not ( |
|
1662 key == "___len___" and |
|
1663 DebugVariables.TooLargeAttribute in keylist): |
1644 continue |
1664 continue |
1645 |
1665 |
1646 # special handling for '__builtins__' (it's way too big) |
1666 # special handling for '__builtins__' (it's way too big) |
1647 if key == '__builtins__': |
1667 if key == '__builtins__': |
1648 rvalue = '<module __builtin__ (built-in)>' |
1668 rvalue = '<module __builtin__ (built-in)>' |
1682 elif not valtype.startswith("PySide") and \ |
1702 elif not valtype.startswith("PySide") and \ |
1683 ConfigVarTypeStrings.index('other') in filter: |
1703 ConfigVarTypeStrings.index('other') in filter: |
1684 continue |
1704 continue |
1685 |
1705 |
1686 try: |
1706 try: |
1687 if valtype not in ['list', 'tuple', 'dict']: |
1707 if valtype not in ['list', 'tuple', 'dict', 'set', |
|
1708 'frozenset']: |
1688 rvalue = repr(value) |
1709 rvalue = repr(value) |
1689 if valtype.startswith('class') and \ |
1710 if valtype.startswith('class') and \ |
1690 rvalue[0] in ['{', '(', '[']: |
1711 rvalue[0] in ['{', '(', '[']: |
1691 rvalue = "" |
1712 rvalue = "" |
1692 else: |
1713 else: |