eric7/Plugins/VcsPlugins/vcsPySvn/SvnDiffDialog.py

branch
eric7
changeset 9152
8a68afaf1ba2
parent 8881
54e42bc2437a
child 9153
506e35e424d5
--- a/eric7/Plugins/VcsPlugins/vcsPySvn/SvnDiffDialog.py	Wed Jun 15 09:44:07 2022 +0200
+++ b/eric7/Plugins/VcsPlugins/vcsPySvn/SvnDiffDialog.py	Thu Jun 16 18:28:59 2022 +0200
@@ -9,10 +9,11 @@
 """
 
 import os
+import pathlib
 
 import pysvn
 
-from PyQt6.QtCore import QFileInfo, QDateTime, Qt, pyqtSlot
+from PyQt6.QtCore import QDateTime, Qt, pyqtSlot
 from PyQt6.QtGui import QTextCursor
 from PyQt6.QtWidgets import QWidget, QDialogButtonBox
 
@@ -431,25 +432,24 @@
         if not fname:
             return  # user aborted
         
-        ext = QFileInfo(fname).suffix()
-        if not ext:
+        fpath = pathlib.Path(fname)
+        if not fpath.suffix:
             ex = selectedFilter.split("(*")[1].split(")")[0]
             if ex:
-                fname += ex
-        if QFileInfo(fname).exists():
+                fpath = fpath.with_suffix(ex)
+        if fpath.exists():
             res = EricMessageBox.yesNo(
                 self,
                 self.tr("Save Diff"),
                 self.tr("<p>The patch file <b>{0}</b> already exists."
-                        " Overwrite it?</p>").format(fname),
+                        " Overwrite it?</p>").format(str(fpath)),
                 icon=EricMessageBox.Warning)
             if not res:
                 return
-        fname = Utilities.toNativeSeparators(fname)
         
         eol = ericApp().getObject("Project").getEolString()
         try:
-            with open(fname, "w", encoding="utf-8", newline="") as f:
+            with fpath.open("w", encoding="utf-8", newline="") as f:
                 f.write(eol.join(self.contents.toPlainText().splitlines()))
         except OSError as why:
             EricMessageBox.critical(
@@ -457,7 +457,7 @@
                 self.tr(
                     '<p>The patch file <b>{0}</b> could not be saved.'
                     '<br>Reason: {1}</p>')
-                .format(fname, str(why)))
+                .format(str(fpath), str(why)))
         
     @pyqtSlot()
     def on_refreshButton_clicked(self):

eric ide

mercurial