--- a/eric7/Templates/TemplateViewer.py Wed Jun 15 09:44:07 2022 +0200 +++ b/eric7/Templates/TemplateViewer.py Thu Jun 16 18:28:59 2022 +0200 @@ -9,9 +9,10 @@ import datetime import os +import pathlib import re -from PyQt6.QtCore import QFile, QFileInfo, QIODevice, Qt, QCoreApplication +from PyQt6.QtCore import QFile, QIODevice, Qt, QCoreApplication from PyQt6.QtWidgets import ( QTreeWidget, QDialog, QApplication, QMenu, QTreeWidgetItem ) @@ -588,22 +589,23 @@ EricFileDialog.DontConfirmOverwrite) if fn: - ext = QFileInfo(fn).suffix() - if not ext: + fpath = pathlib.Path(fn) + if not fpath.suffix: ex = selectedFilter.split("(*")[1].split(")")[0] if ex: - fn += ex - if os.path.exists(fn): + fpath = fpath.with_suffix(ex) + if fpath.exists(): ok = EricMessageBox.yesNo( self, self.tr("Export Templates"), self.tr("""<p>The templates file <b>{0}</b> exists""" - """ already. Overwrite it?</p>""").format(fn)) + """ already. Overwrite it?</p>""") + .format(str(fpath))) else: ok = True if ok: - self.writeTemplates(fn) + self.writeTemplates(str(fpath)) def __reload(self): """