eric7/QScintilla/Exporters/ExporterBase.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 exporter base class. 7 Module implementing the exporter base class.
8 """ 8 """
9 9
10 from PyQt6.QtCore import QFileInfo, QObject, QCoreApplication 10 import pathlib
11
12 from PyQt6.QtCore import QObject, QCoreApplication
11 13
12 from EricWidgets import EricMessageBox, EricFileDialog 14 from EricWidgets import EricMessageBox, EricFileDialog
13
14 import Utilities
15 15
16 16
17 class ExporterBase(QObject): 17 class ExporterBase(QObject):
18 """ 18 """
19 Class implementing the exporter base class. 19 Class implementing the exporter base class.
45 fileFilter, 45 fileFilter,
46 "", 46 "",
47 EricFileDialog.DontConfirmOverwrite) 47 EricFileDialog.DontConfirmOverwrite)
48 48
49 if fn: 49 if fn:
50 ext = QFileInfo(fn).suffix() 50 fpath = pathlib.Path(fn)
51 if not ext: 51 if not fpath.suffix:
52 ex = selectedFilter.split("(*")[1].split(")")[0] 52 ex = selectedFilter.split("(*")[1].split(")")[0]
53 if ex: 53 if ex:
54 fn += ex 54 fpath = fpath.with_suffix(ex)
55 if QFileInfo(fn).exists(): 55 if fpath.exists():
56 res = EricMessageBox.yesNo( 56 res = EricMessageBox.yesNo(
57 self.editor, 57 self.editor,
58 QCoreApplication.translate( 58 QCoreApplication.translate(
59 'Exporter', "Export source"), 59 'Exporter', "Export source"),
60 QCoreApplication.translate( 60 QCoreApplication.translate(
61 'Exporter', 61 'Exporter',
62 "<p>The file <b>{0}</b> already exists." 62 "<p>The file <b>{0}</b> already exists."
63 " Overwrite it?</p>").format(fn), 63 " Overwrite it?</p>").format(str(fpath)),
64 icon=EricMessageBox.Warning) 64 icon=EricMessageBox.Warning)
65 if not res: 65 if not res:
66 return "" 66 return ""
67
68 fn = Utilities.toNativeSeparators(fn)
69 67
70 return fn 68 return str(fpath)
71 69
72 def exportSource(self): 70 def exportSource(self):
73 """ 71 """
74 Public method performing the export. 72 Public method performing the export.
75 73

eric ide

mercurial