DebugClients/Python/DebugClientBase.py

branch
6_0_x
changeset 4120
6f0d4d279aeb
parent 4064
c918bd03f0ff
child 4220
4df8f9fc7ea9
child 4373
54d6d7c772ea
equal deleted inserted replaced
4106:f367d432509a 4120:6f0d4d279aeb
1426 oaccess = '' 1426 oaccess = ''
1427 try: 1427 try:
1428 exec 'mdict = dict%s.__dict__' % access 1428 exec 'mdict = dict%s.__dict__' % access
1429 ndict.update(mdict) # __IGNORE_WARNING__ 1429 ndict.update(mdict) # __IGNORE_WARNING__
1430 exec 'obj = dict%s' % access 1430 exec 'obj = dict%s' % access
1431 if "PyQt4." in str(type(obj)): 1431 if "PyQt4." in str(type(obj)) or \
1432 "PyQt5." in str(type(obj)):
1432 qtVariable = True 1433 qtVariable = True
1433 qvar = obj 1434 qvar = obj
1434 qvtype = ("%s" % type(qvar))[1:-1]\ 1435 qvtype = ("%s" % type(qvar))[1:-1]\
1435 .split()[1][1:-1] 1436 .split()[1][1:-1]
1436 except: 1437 except:
1452 except: 1453 except:
1453 pass 1454 pass
1454 ndict.update(cdict) 1455 ndict.update(cdict)
1455 exec 'obj = dict%s' % access 1456 exec 'obj = dict%s' % access
1456 access = "" 1457 access = ""
1457 if "PyQt4." in str(type(obj)): 1458 if "PyQt4." in str(type(obj)) or \
1459 "PyQt5." in str(type(obj)):
1458 qtVariable = True 1460 qtVariable = True
1459 qvar = obj 1461 qvar = obj
1460 qvtype = ("%s" % type(qvar))[1:-1]\ 1462 qvtype = ("%s" % type(qvar))[1:-1]\
1461 .split()[1][1:-1] 1463 .split()[1][1:-1]
1462 except: 1464 except:
1465 try: 1467 try:
1466 ndict.update(dict[var[i]].__dict__) 1468 ndict.update(dict[var[i]].__dict__)
1467 ndict.update(dict[var[i]].__class__.__dict__) 1469 ndict.update(dict[var[i]].__class__.__dict__)
1468 del rvar[0] 1470 del rvar[0]
1469 obj = dict[var[i]] 1471 obj = dict[var[i]]
1470 if "PyQt4." in str(type(obj)): 1472 if "PyQt4." in str(type(obj)) or \
1473 "PyQt5." in str(type(obj)):
1471 qtVariable = True 1474 qtVariable = True
1472 qvar = obj 1475 qvar = obj
1473 qvtype = ("%s" % type(qvar))[1:-1]\ 1476 qvtype = ("%s" % type(qvar))[1:-1]\
1474 .split()[1][1:-1] 1477 .split()[1][1:-1]
1475 except: 1478 except:
1482 exec 'cdict[v] = dict[var[i]].%s' % v 1485 exec 'cdict[v] = dict[var[i]].%s' % v
1483 except: 1486 except:
1484 pass 1487 pass
1485 ndict.update(cdict) 1488 ndict.update(cdict)
1486 obj = dict[var[i]] 1489 obj = dict[var[i]]
1487 if "PyQt4." in str(type(obj)): 1490 if "PyQt4." in str(type(obj)) or \
1491 "PyQt5." in str(type(obj)):
1488 qtVariable = True 1492 qtVariable = True
1489 qvar = obj 1493 qvar = obj
1490 qvtype = ("%s" % type(qvar))[1:-1]\ 1494 qvtype = ("%s" % type(qvar))[1:-1]\
1491 .split()[1][1:-1] 1495 .split()[1][1:-1]
1492 except: 1496 except:
1494 odict = dict 1498 odict = dict
1495 dict = ndict 1499 dict = ndict
1496 i += 1 1500 i += 1
1497 1501
1498 if qtVariable: 1502 if qtVariable:
1499 vlist = self.__formatQt4Variable(qvar, qvtype) 1503 vlist = self.__formatQtVariable(qvar, qvtype)
1500 elif ("sipThis" in dict.keys() and len(dict) == 1) or \ 1504 elif ("sipThis" in dict.keys() and len(dict) == 1) or \
1501 (len(dict) == 0 and len(udict) > 0): 1505 (len(dict) == 0 and len(udict) > 0):
1502 if access: 1506 if access:
1503 exec 'qvar = udict%s' % access 1507 exec 'qvar = udict%s' % access
1504 # this has to be in line with VariablesViewer.indicators 1508 # this has to be in line with VariablesViewer.indicators
1505 elif rvar and rvar[0][-2:] in ["[]", "()", "{}"]: 1509 elif rvar and rvar[0][-2:] in ["[]", "()", "{}"]:
1506 exec 'qvar = udict["%s"][%s]' % (rvar[0][:-2], rvar[1]) 1510 exec 'qvar = udict["%s"][%s]' % (rvar[0][:-2], rvar[1])
1507 else: 1511 else:
1508 qvar = udict[var[-1]] 1512 qvar = udict[var[-1]]
1509 qvtype = ("%s" % type(qvar))[1:-1].split()[1][1:-1] 1513 qvtype = ("%s" % type(qvar))[1:-1].split()[1][1:-1]
1510 if qvtype.startswith("PyQt4"): 1514 if qvtype.startswith(("PyQt4", "PyQt5")):
1511 vlist = self.__formatQt4Variable(qvar, qvtype) 1515 vlist = self.__formatQtVariable(qvar, qvtype)
1512 else: 1516 else:
1513 vlist = [] 1517 vlist = []
1514 else: 1518 else:
1515 qtVariable = False 1519 qtVariable = False
1516 if len(dict) == 0 and len(udict) > 0: 1520 if len(dict) == 0 and len(udict) > 0:
1520 elif rvar and rvar[0][-2:] in ["[]", "()", "{}"]: 1524 elif rvar and rvar[0][-2:] in ["[]", "()", "{}"]:
1521 exec 'qvar = udict["%s"][%s]' % (rvar[0][:-2], rvar[1]) 1525 exec 'qvar = udict["%s"][%s]' % (rvar[0][:-2], rvar[1])
1522 else: 1526 else:
1523 qvar = udict[var[-1]] 1527 qvar = udict[var[-1]]
1524 qvtype = ("%s" % type(qvar))[1:-1].split()[1][1:-1] 1528 qvtype = ("%s" % type(qvar))[1:-1].split()[1][1:-1]
1525 if qvtype.startswith("PyQt4"): 1529 if qvtype.startswith(("PyQt4", "PyQt5")):
1526 qtVariable = True 1530 qtVariable = True
1527 1531
1528 if qtVariable: 1532 if qtVariable:
1529 vlist = self.__formatQt4Variable(qvar, qvtype) 1533 vlist = self.__formatQtVariable(qvar, qvtype)
1530 else: 1534 else:
1531 # format the dictionary found 1535 # format the dictionary found
1532 if dictkeys is None: 1536 if dictkeys is None:
1533 dictkeys = dict.keys() 1537 dictkeys = dict.keys()
1534 else: 1538 else:
1557 pass 1561 pass
1558 1562
1559 self.write('%s%s\n' % ( 1563 self.write('%s%s\n' % (
1560 DebugProtocol.ResponseVariable, unicode(varlist))) 1564 DebugProtocol.ResponseVariable, unicode(varlist)))
1561 1565
1562 def __formatQt4Variable(self, value, vtype): 1566 def __formatQtVariable(self, value, vtype):
1563 """ 1567 """
1564 Private method to produce a formated output of a simple Qt4/Qt5 type. 1568 Private method to produce a formated output of a simple Qt4/Qt5 type.
1565 1569
1566 @param value variable to be formated 1570 @param value variable to be formated
1567 @param vtype type of the variable to be formatted (string) 1571 @param vtype type of the variable to be formatted (string)
1607 varlist.append(("width", "float", "%g" % value.width())) 1611 varlist.append(("width", "float", "%g" % value.width()))
1608 varlist.append(("height", "float", "%g" % value.height())) 1612 varlist.append(("height", "float", "%g" % value.height()))
1609 elif qttype == 'QColor': 1613 elif qttype == 'QColor':
1610 varlist.append(("name", "str", "%s" % value.name())) 1614 varlist.append(("name", "str", "%s" % value.name()))
1611 r, g, b, a = value.getRgb() 1615 r, g, b, a = value.getRgb()
1612 varlist.append(("rgb", "int", "%d, %d, %d, %d" % (r, g, b, a))) 1616 varlist.append(("rgba", "int", "%d, %d, %d, %d" % (r, g, b, a)))
1613 h, s, v, a = value.getHsv() 1617 h, s, v, a = value.getHsv()
1614 varlist.append(("hsv", "int", "%d, %d, %d, %d" % (h, s, v, a))) 1618 varlist.append(("hsva", "int", "%d, %d, %d, %d" % (h, s, v, a)))
1615 c, m, y, k, a = value.getCmyk() 1619 c, m, y, k, a = value.getCmyk()
1616 varlist.append( 1620 varlist.append(
1617 ("cmyk", "int", "%d, %d, %d, %d, %d" % (c, m, y, k, a))) 1621 ("cmyka", "int", "%d, %d, %d, %d, %d" % (c, m, y, k, a)))
1618 elif qttype == 'QDate': 1622 elif qttype == 'QDate':
1619 varlist.append(("", "QDate", "%s" % value.toString())) 1623 varlist.append(("", "QDate", "%s" % value.toString()))
1620 elif qttype == 'QTime': 1624 elif qttype == 'QTime':
1621 varlist.append(("", "QTime", "%s" % value.toString())) 1625 varlist.append(("", "QTime", "%s" % value.toString()))
1622 elif qttype == 'QDateTime': 1626 elif qttype == 'QDateTime':

eric ide

mercurial