src/eric7/DebugClients/Python/DebugClientBase.py

branch
eric7
changeset 9396
06699e5600a3
parent 9383
1d9a71952123
child 9397
a415cb83dafb
equal deleted inserted replaced
9395:74b24086c146 9396:06699e5600a3
1408 def __dumpVariable(self, var, frmnr, scope, filterList): 1408 def __dumpVariable(self, var, frmnr, scope, filterList):
1409 """ 1409 """
1410 Private method to return the variables of a frame to the debug server. 1410 Private method to return the variables of a frame to the debug server.
1411 1411
1412 @param var list encoded name of the requested variable 1412 @param var list encoded name of the requested variable
1413 @type list of str 1413 @type list of str and int
1414 @param frmnr distance of frame reported on. 0 is the current frame 1414 @param frmnr distance of frame reported on. 0 is the current frame
1415 @type int 1415 @type int
1416 @param scope 1 to report global variables, 0 for local variables 1416 @param scope 1 to report global variables, 0 for local variables
1417 @type int 1417 @type int
1418 @param filterList list of variable types to be filtered 1418 @param filterList list of variable types to be filtered
1446 if scope != -1 and str(var) in self.resolverCache[scope]: 1446 if scope != -1 and str(var) in self.resolverCache[scope]:
1447 varGen = self.resolverCache[scope][str(var)] 1447 varGen = self.resolverCache[scope][str(var)]
1448 idx, varDict = next(varGen) 1448 idx, varDict = next(varGen)
1449 if idx != -2: # more elements available 1449 if idx != -2: # more elements available
1450 var.insert(0, idx) 1450 var.insert(0, idx)
1451 varlist = self.__formatVariablesList(varDict, scope, filterList) 1451 varlist = self.__formatVariablesList(varDict, scope, filterList, var)
1452 elif scope != -1: 1452 elif scope != -1:
1453 variable = varDict 1453 variable = varDict
1454 # Lookup the wanted attribute 1454 # Lookup the wanted attribute
1455 for attribute in var: 1455 for attribute in var:
1456 resolver = DebugVariables.getResolver(variable) 1456 resolver = DebugVariables.getResolver(variable)
1471 # cache for next lookup 1471 # cache for next lookup
1472 self.resolverCache[scope][str(var)] = varGen 1472 self.resolverCache[scope][str(var)] = varGen
1473 1473
1474 idx, varDict = next(varGen) 1474 idx, varDict = next(varGen)
1475 if idx != -2: # more elements available 1475 if idx != -2: # more elements available
1476 varlist = self.__formatVariablesList(varDict, scope, filterList) 1476 varlist = self.__formatVariablesList(
1477 varDict, scope, filterList, var
1478 )
1477 1479
1478 var.insert(0, idx) 1480 var.insert(0, idx)
1479 1481
1480 self.sendJsonCommand( 1482 self.sendJsonCommand(
1481 "ResponseVariable", 1483 "ResponseVariable",
1484 "variable": var, 1486 "variable": var,
1485 "variables": varlist, 1487 "variables": varlist,
1486 }, 1488 },
1487 ) 1489 )
1488 1490
1489 def __formatVariablesList(self, variables, scope, filterList=None): 1491 def __formatVariablesList(self, variables, scope, filterList=None, var=None):
1490 """ 1492 """
1491 Private method to produce a formated variables list. 1493 Private method to produce a formated variables list.
1492 1494
1493 The dictionary passed in to it is scanned. Variables are 1495 The dictionary passed in to it is scanned. Variables are
1494 only added to the list, if their type is not contained 1496 only added to the list, if their type is not contained
1503 Variables are only added to the list, if their name do not match 1505 Variables are only added to the list, if their name do not match
1504 any of the filter expressions. 1506 any of the filter expressions.
1505 @type int 1507 @type int
1506 @param filterList list of variable types to be filtered. 1508 @param filterList list of variable types to be filtered.
1507 Variables are only added to the list, if their type is not 1509 Variables are only added to the list, if their type is not
1508 contained in the filter list. 1510 contained in the filter list. (defaults to None)
1509 @type list of str 1511 @type list of str (optional)
1512 @param var list encoded name of the requested variable (defaults to None)
1513 @type list of str and int (optional)
1510 @return A tuple consisting of a list of formatted variables. Each 1514 @return A tuple consisting of a list of formatted variables. Each
1511 variable entry is a tuple of three elements, the variable name, 1515 variable entry is a tuple of three elements, the variable name,
1512 its type and value. 1516 its type and value.
1513 @rtype list of tuple of (str, str, str) 1517 @rtype list of tuple of (str, str, str)
1514 """ 1518 """
1516 1520
1517 varlist = [] 1521 varlist = []
1518 patternFilterObjects, showFlag = ( 1522 patternFilterObjects, showFlag = (
1519 self.globalsFilterObjects if scope else self.localsFilterObjects 1523 self.globalsFilterObjects if scope else self.localsFilterObjects
1520 ) 1524 )
1525
1526 if var:
1527 var = ".".join(str(v) for v in var)
1521 1528
1522 for variabel in variables: 1529 for variabel in variables:
1523 valtype = None 1530 valtype = None
1524 rvalue = None 1531 rvalue = None
1525 try: 1532 try:
1528 # Special case for some Qt variables, where the real type is 1535 # Special case for some Qt variables, where the real type is
1529 # overwritten 1536 # overwritten
1530 key, valtype, rvalue = variabel 1537 key, valtype, rvalue = variabel
1531 1538
1532 # filter based on the filter pattern 1539 # filter based on the filter pattern
1540 keyPath = "{0}.{1}".format(var, key) if var else key
1533 if patternFilterObjects and ( 1541 if patternFilterObjects and (
1534 (not showFlag and patternFilterObjects.match(str(key))) 1542 (not showFlag and patternFilterObjects.match(str(keyPath)))
1535 or (showFlag and not patternFilterObjects.match(str(key))) 1543 or (showFlag and not patternFilterObjects.match(str(keyPath)))
1536 ): 1544 ):
1537 continue 1545 continue
1538 1546
1539 # filter hidden attributes (filter #0) 1547 # filter hidden attributes (filter #0)
1540 if "__" in filterList and str(key)[:2] == "__": 1548 if "__" in filterList and str(key)[:2] == "__":

eric ide

mercurial