eric6/Debugger/VariablesViewer.py

branch
multi_processing
changeset 7802
eefe954f01e8
parent 7646
39e3db2b4936
parent 7775
4a1db75550bd
child 7863
6725d2549801
equal deleted inserted replaced
7646:39e3db2b4936 7802:eefe954f01e8
5 5
6 """ 6 """
7 Module implementing the variables viewer view based on QTreeView. 7 Module implementing the variables viewer view based on QTreeView.
8 """ 8 """
9 9
10
11 import ast 10 import ast
12 11 import re
13 from PyQt5.QtCore import (Qt, QAbstractItemModel, QModelIndex, QRegExp, 12
14 QCoreApplication, QSortFilterProxyModel, pyqtSignal) 13 from PyQt5.QtCore import (
14 Qt, QAbstractItemModel, QModelIndex, QCoreApplication,
15 QSortFilterProxyModel, pyqtSignal
16 )
15 from PyQt5.QtGui import QBrush, QFontMetrics 17 from PyQt5.QtGui import QBrush, QFontMetrics
16 from PyQt5.QtWidgets import QTreeView, QAbstractItemView, QToolTip, QMenu 18 from PyQt5.QtWidgets import QTreeView, QAbstractItemView, QToolTip, QMenu
17 19
18 from E5Gui.E5Application import e5App 20 from E5Gui.E5Application import e5App
19 21
39 'frozenset': '{}', # __IGNORE_WARNING_M613__ 41 'frozenset': '{}', # __IGNORE_WARNING_M613__
40 'numpy.ndarray': '[ndarray]', # __IGNORE_WARNING_M613__ 42 'numpy.ndarray': '[ndarray]', # __IGNORE_WARNING_M613__
41 } 43 }
42 44
43 # Initialize regular expression for unprintable strings 45 # Initialize regular expression for unprintable strings
44 rx_nonprintable = QRegExp(r"""(\\x\d\d)+""") 46 rx_nonprintable = re.compile(r"""(\\x\d\d)+""")
45 47
46 noOfItemsStr = QCoreApplication.translate("VariablesViewer", "{0} items") 48 noOfItemsStr = QCoreApplication.translate("VariablesViewer", "{0} items")
47 unsized = QCoreApplication.translate("VariablesViewer", "unsized") 49 unsized = QCoreApplication.translate("VariablesViewer", "unsized")
48 50
49 arrayTypes = { 51 arrayTypes = {
192 194
193 elif dtype == "Shiboken.EnumType": 195 elif dtype == "Shiboken.EnumType":
194 self.hasChildren = True 196 self.hasChildren = True
195 197
196 elif dtype in ['str', 'unicode']: 198 elif dtype in ['str', 'unicode']:
197 if VariableItem.rx_nonprintable.indexIn(dvalue) == -1: 199 if VariableItem.rx_nonprintable.search(dvalue) is None:
198 try: 200 try:
199 dvalue = ast.literal_eval(dvalue) 201 dvalue = ast.literal_eval(dvalue)
200 except Exception: # secok 202 except Exception: # secok
201 pass 203 pass
202 dvalue = str(dvalue) 204 dvalue = str(dvalue)
809 self.openItems.append(pathlist) 811 self.openItems.append(pathlist)
810 if pathlist in self.closedItems: 812 if pathlist in self.closedItems:
811 self.closedItems.remove(pathlist) 813 self.closedItems.remove(pathlist)
812 self.getMore() 814 self.getMore()
813 else: 815 else:
814 self.openItems.remove(pathlist) 816 if pathlist in self.openItems:
817 self.openItems.remove(pathlist)
815 self.closedItems.append(pathlist) 818 self.closedItems.append(pathlist)
816 819
817 def __buildTreePath(self, parent): 820 def __buildTreePath(self, parent):
818 """ 821 """
819 Private method to build up a path from the root to parent. 822 Private method to build up a path from the root to parent.
1193 1196
1194 name = ''.join(nlist) 1197 name = ''.join(nlist)
1195 # now show the dialog 1198 # now show the dialog
1196 from .VariableDetailDialog import VariableDetailDialog 1199 from .VariableDetailDialog import VariableDetailDialog
1197 dlg = VariableDetailDialog(name, vtype, val) 1200 dlg = VariableDetailDialog(name, vtype, val)
1198 dlg.exec_() 1201 dlg.exec()
1199 1202
1200 def __configure(self): 1203 def __configure(self):
1201 """ 1204 """
1202 Private method to open the configuration dialog. 1205 Private method to open the configuration dialog.
1203 """ 1206 """

eric ide

mercurial