src/eric7/Project/Project.py

branch
eric7
changeset 9624
b47dfa7a137d
parent 9612
93b496cc3c88
child 9626
5bb5c85d71c3
--- a/src/eric7/Project/Project.py	Sun Dec 18 14:19:10 2022 +0100
+++ b/src/eric7/Project/Project.py	Sun Dec 18 19:33:46 2022 +0100
@@ -33,7 +33,7 @@
 from PyQt6.QtGui import QAction, QKeySequence
 from PyQt6.QtWidgets import QDialog, QInputDialog, QLineEdit, QMenu, QToolBar
 
-from eric7 import Globals, Preferences, Utilities
+from eric7 import Preferences, Utilities
 from eric7.CodeFormatting.BlackFormattingAction import BlackFormattingAction
 from eric7.CodeFormatting.BlackUtilities import aboutBlack
 from eric7.CodeFormatting.IsortFormattingAction import IsortFormattingAction
@@ -52,6 +52,12 @@
 from eric7.EricXML.UserProjectReader import UserProjectReader
 from eric7.Globals import recentNameProject
 from eric7.Sessions.SessionFile import SessionFile
+from eric7.SystemUtilities import (
+    FileSystemUtilities,
+    OSUtilities,
+    PythonUtilities,
+    QtUtilities,
+)
 from eric7.Tasks.TasksFile import TasksFile
 from eric7.UI import Config
 from eric7.UI.NotificationWidget import NotificationTypes
@@ -347,12 +353,12 @@
             "JavaScript": ["Other"],
         }
 
-        if Utilities.checkPyside(variant=2):
+        if QtUtilities.checkPyside(variant=2):
             self.__projectTypes["PySide2"] = self.tr("PySide2 GUI")
             self.__projectTypes["PySide2C"] = self.tr("PySide2 Console")
             self.__projectProgLanguages["Python3"].extend(["PySide2", "PySide2C"])
 
-        if Utilities.checkPyside(variant=6):
+        if QtUtilities.checkPyside(variant=6):
             self.__projectTypes["PySide6"] = self.tr("PySide6 GUI")
             self.__projectTypes["PySide6C"] = self.tr("PySide6 Console")
             self.__projectProgLanguages["Python3"].extend(["PySide6", "PySide6C"])
@@ -1896,7 +1902,7 @@
             if target != "":
                 for fn in fnames:
                     targetfile = os.path.join(target, os.path.basename(fn))
-                    if not Utilities.samepath(os.path.dirname(fn), target):
+                    if not FileSystemUtilities.samepath(os.path.dirname(fn), target):
                         try:
                             if not os.path.isdir(target):
                                 os.makedirs(target)
@@ -1971,7 +1977,9 @@
                 )
             return
 
-        if not Utilities.samepath(target, source) and not os.path.isdir(target):
+        if not FileSystemUtilities.samepath(target, source) and not os.path.isdir(
+            target
+        ):
             try:
                 os.makedirs(target)
             except OSError as why:
@@ -1991,7 +1999,7 @@
                     continue
 
             targetfile = os.path.join(target, os.path.basename(file))
-            if not Utilities.samepath(target, source):
+            if not FileSystemUtilities.samepath(target, source):
                 try:
                     if os.path.exists(targetfile):
                         res = EricMessageBox.yesNo(
@@ -2149,7 +2157,7 @@
             )
             if not newfn:
                 return False
-            newfn = Utilities.toNativeSeparators(newfn)
+            newfn = FileSystemUtilities.toNativeSeparators(newfn)
 
         if os.path.exists(newfn):
             res = EricMessageBox.yesNo(
@@ -2830,7 +2838,7 @@
             # search the project directory for files with known extensions
             filespecs = list(self.__pdata["FILETYPES"].keys())
             for filespec in filespecs:
-                files = Utilities.direntries(self.ppath, True, filespec)
+                files = FileSystemUtilities.direntries(self.ppath, True, filespec)
                 for file in files:
                     self.appendFile(file)
 
@@ -2850,10 +2858,10 @@
                     tpd = self.__pdata["TRANSLATIONPATTERN"].split("%language%")[0]
             else:
                 pattern = "*.ts"
-            tslist.extend(Utilities.direntries(tpd, True, pattern))
+            tslist.extend(FileSystemUtilities.direntries(tpd, True, pattern))
             pattern = self.__binaryTranslationFile(pattern)
             if pattern:
-                tslist.extend(Utilities.direntries(tpd, True, pattern))
+                tslist.extend(FileSystemUtilities.direntries(tpd, True, pattern))
             if tslist:
                 if "_" in os.path.basename(tslist[0]):
                     # the first entry determines the mainscript name
@@ -2902,7 +2910,7 @@
                             self.__pdata["TRANSLATIONPATTERN"]
                         ).replace("%language%", "*")
                         pattern = self.__binaryTranslationFile(pattern)
-                        qmlist = Utilities.direntries(tpd, True, pattern)
+                        qmlist = FileSystemUtilities.direntries(tpd, True, pattern)
                         for qm in qmlist:
                             self.__pdata["TRANSLATIONS"].append(qm)
                             self.projectFileAdded.emit(qm, "TRANSLATIONS")
@@ -3116,7 +3124,7 @@
             fn = EricFileDialog.getOpenFileName(
                 self.parent(),
                 self.tr("Open project"),
-                Preferences.getMultiProject("Workspace") or Utilities.getHomeDir(),
+                Preferences.getMultiProject("Workspace") or OSUtilities.getHomeDir(),
                 self.tr("Project Files (*.epj);;XML Project Files (*.e4p)"),
             )
 
@@ -3312,7 +3320,7 @@
         defaultPath = (
             self.ppath
             if self.ppath
-            else (Preferences.getMultiProject("Workspace") or Utilities.getHomeDir())
+            else (Preferences.getMultiProject("Workspace") or OSUtilities.getHomeDir())
         )
         fn, selectedFilter = EricFileDialog.getSaveFileNameAndFilter(
             self.parent(),
@@ -3750,8 +3758,12 @@
         """
         return bool(self.ppath) and (
             path == self.ppath
-            or Utilities.normcasepath(Utilities.toNativeSeparators(path)).startswith(
-                Utilities.normcasepath(Utilities.toNativeSeparators(self.ppath + "/"))
+            or FileSystemUtilities.normcasepath(
+                FileSystemUtilities.toNativeSeparators(path)
+            ).startswith(
+                FileSystemUtilities.normcasepath(
+                    FileSystemUtilities.toNativeSeparators(self.ppath + "/")
+                )
             )
         )
 
@@ -3827,7 +3839,7 @@
         @return project relative path or unchanged path, if path doesn't
             belong to the project (string)
         """
-        return Utilities.fromNativeSeparators(self.getRelativePath(path))
+        return FileSystemUtilities.fromNativeSeparators(self.getRelativePath(path))
 
     def getAbsolutePath(self, fn):
         """
@@ -3850,7 +3862,7 @@
         @return absolute path (string)
         """
         if not os.path.isabs(fn):
-            fn = os.path.join(self.ppath, Utilities.toNativeSeparators(fn))
+            fn = os.path.join(self.ppath, FileSystemUtilities.toNativeSeparators(fn))
         return fn
 
     def getEolString(self):
@@ -3967,7 +3979,7 @@
                     .getVirtualenvInterpreter(venvName)
                 )
         if not interpreter and resolveGlobal:
-            interpreter = Globals.getPythonExecutable()
+            interpreter = PythonUtilities.getPythonExecutable()
 
         return interpreter
 
@@ -4062,7 +4074,7 @@
         ):
             return True
 
-        if Utilities.isWindowsPlatform():
+        if OSUtilities.isWindowsPlatform():
             # try the above case-insensitive
             newfn = newfn.lower()
             if any(entry.lower() == newfn for entry in self.__pdata[group]):
@@ -5390,7 +5402,7 @@
         with the central store.
         """
         for recent in self.recent[:]:
-            if Utilities.samepath(self.pfile, recent):
+            if FileSystemUtilities.samepath(self.pfile, recent):
                 self.recent.remove(recent)
         self.recent.insert(0, self.pfile)
         maxRecent = Preferences.getProject("RecentNumber")
@@ -5410,7 +5422,7 @@
             formatStr = "&{0:d}. {1}" if idx < 10 else "{0:d}. {1}"
             act = self.recentMenu.addAction(
                 formatStr.format(
-                    idx, Utilities.compactPath(rp, self.ui.maxMenuFilePathLen)
+                    idx, FileSystemUtilities.compactPath(rp, self.ui.maxMenuFilePathLen)
                 )
             )
             act.setData(rp)
@@ -5520,7 +5532,7 @@
                 if ns.startswith("."):
                     continue
                 if (
-                    Utilities.isWindowsPlatform()
+                    OSUtilities.isWindowsPlatform()
                     and os.path.isdir(os.path.join(curpath, ns))
                     and ns.startswith("_")
                 ):
@@ -6139,7 +6151,9 @@
                 lst.extend(
                     [
                         self.getRelativePath(p)
-                        for p in Utilities.direntries(self.getAbsolutePath(entry), True)
+                        for p in FileSystemUtilities.direntries(
+                            self.getAbsolutePath(entry), True
+                        )
                     ]
                 )
                 continue
@@ -6163,7 +6177,9 @@
             with open(pkglist, "w", encoding="utf-8", newline=newline) as pkglistFile:
                 pkglistFile.write("\n".join(header) + "\n")
                 pkglistFile.write(
-                    "\n".join([Utilities.fromNativeSeparators(f) for f in lst])
+                    "\n".join(
+                        [FileSystemUtilities.fromNativeSeparators(f) for f in lst]
+                    )
                 )
                 pkglistFile.write("\n")
                 # ensure the file ends with an empty line

eric ide

mercurial