eric7/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py

branch
eric7
changeset 9152
8a68afaf1ba2
parent 8912
1bd5e972252e
child 9153
506e35e424d5
diff -r 8c5296fe3056 -r 8a68afaf1ba2 eric7/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py
--- a/eric7/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py	Wed Jun 15 09:44:07 2022 +0200
+++ b/eric7/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py	Thu Jun 16 18:28:59 2022 +0200
@@ -7,9 +7,9 @@
 Module implementing the Editor Highlighting Styles configuration page.
 """
 
-import os
+import pathlib
 
-from PyQt6.QtCore import pyqtSlot, Qt, QFileInfo, QFile, QIODevice
+from PyQt6.QtCore import pyqtSlot, Qt, QFile, QIODevice
 from PyQt6.QtGui import QFont, QColor
 from PyQt6.QtWidgets import (
     QColorDialog, QFontDialog, QInputDialog, QMenu, QTreeWidgetItem, QDialog
@@ -562,19 +562,19 @@
         if not fn:
             return
         
-        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
+                fpath = fpath.with_suffix(ex)
         
         ok = (
             EricMessageBox.yesNo(
                 self,
                 self.tr("Export Highlighting Styles"),
                 self.tr("""<p>The highlighting styles file <b>{0}</b> exists"""
-                        """ already. Overwrite it?</p>""").format(fn))
-            if os.path.exists(fn) else
+                        """ already. Overwrite it?</p>""").format(str(fpath)))
+            if fpath.exists() else
             True
         )
         
@@ -583,7 +583,7 @@
                 HighlightingStylesFile
             )
             highlightingStylesFile = HighlightingStylesFile()
-            highlightingStylesFile.writeFile(fn, lexers)
+            highlightingStylesFile.writeFile(str(fpath), lexers)
     
     def __importStyles(self, importAll=False):
         """

eric ide

mercurial