eric7/Debugger/CallStackViewer.py

branch
eric7
changeset 9152
8a68afaf1ba2
parent 8881
54e42bc2437a
child 9153
506e35e424d5
equal deleted inserted replaced
9151:8c5296fe3056 9152:8a68afaf1ba2
5 5
6 """ 6 """
7 Module implementing the Call Stack viewer widget. 7 Module implementing the Call Stack viewer widget.
8 """ 8 """
9 9
10 from PyQt6.QtCore import pyqtSignal, Qt, QFileInfo 10 import pathlib
11
12 from PyQt6.QtCore import pyqtSignal, Qt
11 from PyQt6.QtWidgets import ( 13 from PyQt6.QtWidgets import (
12 QTreeWidget, QTreeWidgetItem, QMenu, QWidget, QVBoxLayout, QLabel 14 QTreeWidget, QTreeWidgetItem, QMenu, QWidget, QVBoxLayout, QLabel
13 ) 15 )
14 16
15 from EricWidgets.EricApplication import ericApp 17 from EricWidgets.EricApplication import ericApp
16 from EricWidgets import EricFileDialog, EricMessageBox 18 from EricWidgets import EricFileDialog, EricMessageBox
17
18 import Utilities
19 19
20 20
21 class CallStackViewer(QWidget): 21 class CallStackViewer(QWidget):
22 """ 22 """
23 Class implementing the Call Stack viewer widget. 23 Class implementing the Call Stack viewer widget.
194 "", 194 "",
195 self.tr("Text Files (*.txt);;All Files (*)"), 195 self.tr("Text Files (*.txt);;All Files (*)"),
196 None, 196 None,
197 EricFileDialog.DontConfirmOverwrite) 197 EricFileDialog.DontConfirmOverwrite)
198 if fname: 198 if fname:
199 ext = QFileInfo(fname).suffix() 199 fpath = pathlib.Path(fname)
200 if not ext: 200 if not fpath.suffix:
201 ex = selectedFilter.split("(*")[1].split(")")[0] 201 ex = selectedFilter.split("(*")[1].split(")")[0]
202 if ex: 202 if ex:
203 fname += ex 203 fpath = fpath.with_suffix(ex)
204 if QFileInfo(fname).exists(): 204 if fpath.exists():
205 res = EricMessageBox.yesNo( 205 res = EricMessageBox.yesNo(
206 self, 206 self,
207 self.tr("Save Call Stack Info"), 207 self.tr("Save Call Stack Info"),
208 self.tr("<p>The file <b>{0}</b> already exists." 208 self.tr("<p>The file <b>{0}</b> already exists."
209 " Overwrite it?</p>").format(fname), 209 " Overwrite it?</p>").format(str(fpath)),
210 icon=EricMessageBox.Warning) 210 icon=EricMessageBox.Warning)
211 if not res: 211 if not res:
212 return 212 return
213 fname = Utilities.toNativeSeparators(fname)
214 213
215 try: 214 try:
216 title = self.tr("Call Stack of '{0}'").format( 215 title = self.tr("Call Stack of '{0}'").format(
217 self.__debuggerLabel.text()) 216 self.__debuggerLabel.text())
218 with open(fname, "w", encoding="utf-8") as f: 217 with fpath.open("w", encoding="utf-8") as f:
219 f.write("{0}\n".format(title)) 218 f.write("{0}\n".format(title))
220 f.write("{0}\n\n".format(len(title) * "=")) 219 f.write("{0}\n\n".format(len(title) * "="))
221 itm = self.__callStackList.topLevelItem(0) 220 itm = self.__callStackList.topLevelItem(0)
222 while itm is not None: 221 while itm is not None:
223 f.write("{0}\n".format(itm.text(0))) 222 f.write("{0}\n".format(itm.text(0)))
228 self, 227 self,
229 self.tr("Error saving Call Stack Info"), 228 self.tr("Error saving Call Stack Info"),
230 self.tr("""<p>The call stack info could not be""" 229 self.tr("""<p>The call stack info could not be"""
231 """ written to <b>{0}</b></p>""" 230 """ written to <b>{0}</b></p>"""
232 """<p>Reason: {1}</p>""") 231 """<p>Reason: {1}</p>""")
233 .format(fname, str(err))) 232 .format(str(fpath), str(err)))

eric ide

mercurial