--- a/src/eric7/Templates/TemplateViewer.py Mon Feb 19 19:17:04 2024 +0100 +++ b/src/eric7/Templates/TemplateViewer.py Wed Feb 21 10:56:24 2024 +0100 @@ -12,14 +12,13 @@ import pathlib import re -from PyQt6.QtCore import QCoreApplication, QFile, QIODevice, Qt, pyqtSlot +from PyQt6.QtCore import QCoreApplication, Qt, pyqtSlot from PyQt6.QtWidgets import QApplication, QDialog, QMenu, QTreeWidget, QTreeWidgetItem from eric7 import Globals, Preferences from eric7.EricGui import EricPixmapCache from eric7.EricWidgets import EricFileDialog, EricMessageBox from eric7.EricWidgets.EricApplication import ericApp -from eric7.EricXML.TemplatesReader import TemplatesReader from .TemplatePropertiesDialog import TemplatePropertiesDialog from .TemplatesFile import TemplatesFile @@ -604,11 +603,7 @@ self, self.tr("Import Templates"), "", - self.tr( - "Templates Files (*.ecj);;" - "XML Templates Files (*.e4c);;" - "All Files (*)" - ), + self.tr("Templates Files (*.ecj);;All Files (*)"), ) if fn: @@ -1045,36 +1040,17 @@ def readTemplates(self, filename=None): """ - Public method to read in the templates file (.e4c). + Public method to read in the templates file (.ecj). @param filename name of a templates file to read @type str """ if filename is None: - # new JSON based file first filename = os.path.join(Globals.getConfigDir(), "eric7templates.ecj") if not os.path.exists(filename): - # old XML based file second - filename = os.path.join(Globals.getConfigDir(), "eric7templates.e4c") - if not os.path.exists(filename): - return + return - if filename.endswith(".ecj"): - self.__templatesFile.readFile(filename) - else: - f = QFile(filename) - if f.open(QIODevice.OpenModeFlag.ReadOnly): - reader = TemplatesReader(f, viewer=self) - reader.readXML() - f.close() - else: - EricMessageBox.critical( - self, - self.tr("Read Templates"), - self.tr( - "<p>The templates file <b>{0}</b> could not be read.</p>" - ).format(filename), - ) + self.__templatesFile.readFile(filename) def __configure(self): """