DebugClients/Python3/DebugClientBase.py

changeset 4118
3c9fa4b8869d
parent 4063
b7269498aa95
child 4220
4df8f9fc7ea9
child 4373
54d6d7c772ea
equal deleted inserted replaced
4117:40d4272b538a 4118:3c9fa4b8869d
1445 loc = {"dict": dict} 1445 loc = {"dict": dict}
1446 exec('mdict = dict{0!s}.__dict__\nobj = dict{0!s}' 1446 exec('mdict = dict{0!s}.__dict__\nobj = dict{0!s}'
1447 .format(access), globals(), loc) 1447 .format(access), globals(), loc)
1448 mdict = loc["mdict"] 1448 mdict = loc["mdict"]
1449 obj = loc["obj"] 1449 obj = loc["obj"]
1450 if "PyQt4." in str(type(obj)): 1450 if "PyQt4." in str(type(obj)) or \
1451 "PyQt5." in str(type(obj)):
1451 qtVariable = True 1452 qtVariable = True
1452 qvar = obj 1453 qvar = obj
1453 qvtype = str(type(qvar))[1:-1].split()[1][1:-1] 1454 qvtype = str(type(qvar))[1:-1].split()[1][1:-1]
1454 ndict.update(mdict) 1455 ndict.update(mdict)
1455 except: 1456 except:
1478 ndict.update(loc["cdict"]) 1479 ndict.update(loc["cdict"])
1479 exec('obj = dict{0!s}'.format(access), 1480 exec('obj = dict{0!s}'.format(access),
1480 globals(), loc) 1481 globals(), loc)
1481 obj = loc["obj"] 1482 obj = loc["obj"]
1482 access = "" 1483 access = ""
1483 if "PyQt4." in str(type(obj)): 1484 if "PyQt4." in str(type(obj)) or \
1485 "PyQt5." in str(type(obj)):
1484 qtVariable = True 1486 qtVariable = True
1485 qvar = obj 1487 qvar = obj
1486 qvtype = str(type(qvar))[1:-1].split()[1][1:-1] 1488 qvtype = str(type(qvar))[1:-1].split()[1][1:-1]
1487 except: 1489 except:
1488 pass 1490 pass
1490 try: 1492 try:
1491 ndict.update(dict[var[i]].__dict__) 1493 ndict.update(dict[var[i]].__dict__)
1492 ndict.update(dict[var[i]].__class__.__dict__) 1494 ndict.update(dict[var[i]].__class__.__dict__)
1493 del rvar[0] 1495 del rvar[0]
1494 obj = dict[var[i]] 1496 obj = dict[var[i]]
1495 if "PyQt4." in str(type(obj)): 1497 if "PyQt4." in str(type(obj)) or \
1498 "PyQt5." in str(type(obj)):
1496 qtVariable = True 1499 qtVariable = True
1497 qvar = obj 1500 qvar = obj
1498 qvtype = str(type(qvar))[1:-1].split()[1][1:-1] 1501 qvtype = str(type(qvar))[1:-1].split()[1][1:-1]
1499 except: 1502 except:
1500 pass 1503 pass
1510 globals(), loc) 1513 globals(), loc)
1511 except: 1514 except:
1512 pass 1515 pass
1513 ndict.update(loc["cdict"]) 1516 ndict.update(loc["cdict"])
1514 obj = dict[var[i]] 1517 obj = dict[var[i]]
1515 if "PyQt4." in str(type(obj)): 1518 if "PyQt4." in str(type(obj)) or \
1519 "PyQt5." in str(type(obj)):
1516 qtVariable = True 1520 qtVariable = True
1517 qvar = obj 1521 qvar = obj
1518 qvtype = str(type(qvar))[1:-1].split()[1][1:-1] 1522 qvtype = str(type(qvar))[1:-1].split()[1][1:-1]
1519 except: 1523 except:
1520 pass 1524 pass
1521 odict = dict 1525 odict = dict
1522 dict = ndict 1526 dict = ndict
1523 i += 1 1527 i += 1
1524 1528
1525 if qtVariable: 1529 if qtVariable:
1526 vlist = self.__formatQt4Variable(qvar, qvtype) 1530 vlist = self.__formatQtVariable(qvar, qvtype)
1527 elif ("sipThis" in dict.keys() and len(dict) == 1) or \ 1531 elif ("sipThis" in dict.keys() and len(dict) == 1) or \
1528 (len(dict) == 0 and len(udict) > 0): 1532 (len(dict) == 0 and len(udict) > 0):
1529 if access: 1533 if access:
1530 loc = {"udict": udict} 1534 loc = {"udict": udict}
1531 exec('qvar = udict{0!s}'.format(access), globals(), loc) 1535 exec('qvar = udict{0!s}'.format(access), globals(), loc)
1538 globals(), loc) 1542 globals(), loc)
1539 qvar = loc["qvar"] 1543 qvar = loc["qvar"]
1540 else: 1544 else:
1541 qvar = udict[var[-1]] 1545 qvar = udict[var[-1]]
1542 qvtype = str(type(qvar))[1:-1].split()[1][1:-1] 1546 qvtype = str(type(qvar))[1:-1].split()[1][1:-1]
1543 if qvtype.startswith("PyQt4"): 1547 if qvtype.startswith(("PyQt4", "PyQt5")):
1544 vlist = self.__formatQt4Variable(qvar, qvtype) 1548 vlist = self.__formatQtVariable(qvar, qvtype)
1545 else: 1549 else:
1546 vlist = [] 1550 vlist = []
1547 else: 1551 else:
1548 qtVariable = False 1552 qtVariable = False
1549 if len(dict) == 0 and len(udict) > 0: 1553 if len(dict) == 0 and len(udict) > 0:
1559 rvar[0][:-2], rvar[1]), globals(), loc) 1563 rvar[0][:-2], rvar[1]), globals(), loc)
1560 qvar = loc["qvar"] 1564 qvar = loc["qvar"]
1561 else: 1565 else:
1562 qvar = udict[var[-1]] 1566 qvar = udict[var[-1]]
1563 qvtype = str(type(qvar))[1:-1].split()[1][1:-1] 1567 qvtype = str(type(qvar))[1:-1].split()[1][1:-1]
1564 if qvtype.startswith("PyQt4"): 1568 if qvtype.startswith(("PyQt4", "PyQt5")):
1565 qtVariable = True 1569 qtVariable = True
1566 1570
1567 if qtVariable: 1571 if qtVariable:
1568 vlist = self.__formatQt4Variable(qvar, qvtype) 1572 vlist = self.__formatQtVariable(qvar, qvtype)
1569 else: 1573 else:
1570 # format the dictionary found 1574 # format the dictionary found
1571 if dictkeys is None: 1575 if dictkeys is None:
1572 dictkeys = dict.keys() 1576 dictkeys = dict.keys()
1573 else: 1577 else:
1602 pass 1606 pass
1603 1607
1604 self.write('{0}{1}\n'.format( 1608 self.write('{0}{1}\n'.format(
1605 DebugProtocol.ResponseVariable, str(varlist))) 1609 DebugProtocol.ResponseVariable, str(varlist)))
1606 1610
1607 def __formatQt4Variable(self, value, vtype): 1611 def __formatQtVariable(self, value, vtype):
1608 """ 1612 """
1609 Private method to produce a formatted output of a simple Qt4/Qt5 type. 1613 Private method to produce a formatted output of a simple Qt4/Qt5 type.
1610 1614
1611 @param value variable to be formatted 1615 @param value variable to be formatted
1612 @param vtype type of the variable to be formatted (string) 1616 @param vtype type of the variable to be formatted (string)
1652 varlist.append(("height", "float", "{0:g}".format(value.height()))) 1656 varlist.append(("height", "float", "{0:g}".format(value.height())))
1653 elif qttype == 'QColor': 1657 elif qttype == 'QColor':
1654 varlist.append(("name", "str", "{0}".format(value.name()))) 1658 varlist.append(("name", "str", "{0}".format(value.name())))
1655 r, g, b, a = value.getRgb() 1659 r, g, b, a = value.getRgb()
1656 varlist.append( 1660 varlist.append(
1657 ("rgb", "int", 1661 ("rgba", "int",
1658 "{0:d}, {1:d}, {2:d}, {3:d}".format(r, g, b, a))) 1662 "{0:d}, {1:d}, {2:d}, {3:d}".format(r, g, b, a)))
1659 h, s, v, a = value.getHsv() 1663 h, s, v, a = value.getHsv()
1660 varlist.append( 1664 varlist.append(
1661 ("hsv", "int", 1665 ("hsva", "int",
1662 "{0:d}, {1:d}, {2:d}, {3:d}".format(h, s, v, a))) 1666 "{0:d}, {1:d}, {2:d}, {3:d}".format(h, s, v, a)))
1663 c, m, y, k, a = value.getCmyk() 1667 c, m, y, k, a = value.getCmyk()
1664 varlist.append( 1668 varlist.append(
1665 ("cmyk", "int", 1669 ("cmyka", "int",
1666 "{0:d}, {1:d}, {2:d}, {3:d}, {4:d}".format(c, m, y, k, a))) 1670 "{0:d}, {1:d}, {2:d}, {3:d}, {4:d}".format(c, m, y, k, a)))
1667 elif qttype == 'QDate': 1671 elif qttype == 'QDate':
1668 varlist.append(("", "QDate", "{0}".format(value.toString()))) 1672 varlist.append(("", "QDate", "{0}".format(value.toString())))
1669 elif qttype == 'QTime': 1673 elif qttype == 'QTime':
1670 varlist.append(("", "QTime", "{0}".format(value.toString()))) 1674 varlist.append(("", "QTime", "{0}".format(value.toString())))

eric ide

mercurial