diff -r 0b936ff1bbb9 -r a2bc06a54d9d src/eric7/Project/Project.py --- a/src/eric7/Project/Project.py Sun Nov 06 11:22:39 2022 +0100 +++ b/src/eric7/Project/Project.py Mon Nov 07 17:19:58 2022 +0100 @@ -44,6 +44,11 @@ from eric7.EricWidgets.EricApplication import ericApp from eric7.EricWidgets.EricListSelectionDialog import EricListSelectionDialog from eric7.EricWidgets.EricProgressDialog import EricProgressDialog +from eric7.EricXML.DebuggerPropertiesReader import DebuggerPropertiesReader +from eric7.EricXML.ProjectReader import ProjectReader +from eric7.EricXML.SessionReader import SessionReader +from eric7.EricXML.TasksReader import TasksReader +from eric7.EricXML.UserProjectReader import UserProjectReader from eric7.Globals import recentNameProject from eric7.Sessions.SessionFile import SessionFile from eric7.Tasks.TasksFile import TasksFile @@ -51,6 +56,7 @@ from eric7.UI.NotificationWidget import NotificationTypes from .DebuggerPropertiesFile import DebuggerPropertiesFile +from .ProjectBrowserModel import ProjectBrowserModel from .ProjectFile import ProjectFile from .UserProjectFile import UserProjectFile @@ -220,8 +226,6 @@ else: self.vcs = self.initVCS() - from .ProjectBrowserModel import ProjectBrowserModel - self.__model = ProjectBrowserModel(self) self.codemetrics = None @@ -865,8 +869,6 @@ # old XML based format f = QFile(fn) if f.open(QIODevice.OpenModeFlag.ReadOnly): - from eric7.EricXML.ProjectReader import ProjectReader - reader = ProjectReader(f, self) reader.readXML() res = not reader.hasError() @@ -1007,8 +1009,6 @@ if os.path.exists(fn): f = QFile(fn) if f.open(QIODevice.OpenModeFlag.ReadOnly): - from eric7.EricXML.UserProjectReader import UserProjectReader - reader = UserProjectReader(f, self) reader.readXML() f.close() @@ -1083,8 +1083,6 @@ if os.path.exists(fn): f = QFile(fn) if f.open(QIODevice.OpenModeFlag.ReadOnly): - from eric7.EricXML.SessionReader import SessionReader - reader = SessionReader(f, False) reader.readXML(quiet=quiet) f.close() @@ -1178,8 +1176,6 @@ if os.path.exists(fn): f = QFile(fn) if f.open(QIODevice.OpenModeFlag.ReadOnly): - from eric7.EricXML.TasksReader import TasksReader - reader = TasksReader(f, True) reader.readXML() f.close() @@ -1257,10 +1253,6 @@ f = QFile(fn) if f.open(QIODevice.OpenModeFlag.ReadOnly): - from eric7.EricXML.DebuggerPropertiesReader import ( - DebuggerPropertiesReader, - ) - reader = DebuggerPropertiesReader(f, self) reader.readXML(quiet=quiet) f.close() @@ -1481,6 +1473,8 @@ """ Public slot used to add a language to the project. """ + from .AddLanguageDialog import AddLanguageDialog + if not self.pdata["TRANSLATIONPATTERN"]: EricMessageBox.critical( self.ui, @@ -1489,8 +1483,6 @@ ) return - from .AddLanguageDialog import AddLanguageDialog - dlg = AddLanguageDialog(self.parent()) if dlg.exec() == QDialog.DialogCode.Accepted: lang = dlg.getSelectedLanguage() @@ -1582,7 +1574,7 @@ @param langFile the translation file to be removed (string) """ try: - from send2trash import send2trash as s2t + from send2trash import send2trash as s2t # __IGNORE_WARNING_I10__ except ImportError: s2t = os.remove @@ -1736,9 +1728,10 @@ @param startdir start directory for the selection dialog @type str """ + from .AddFileDialog import AddFileDialog + if startdir is None: startdir = self.ppath - from .AddFileDialog import AddFileDialog dlg = AddFileDialog(self, self.parent(), fileTypeFilter, startdir=startdir) if dlg.exec() == QDialog.DialogCode.Accepted: @@ -1907,9 +1900,10 @@ @param startdir start directory for the selection dialog @type str """ + from .AddDirectoryDialog import AddDirectoryDialog + if startdir is None: startdir = self.ppath - from .AddDirectoryDialog import AddDirectoryDialog dlg = AddDirectoryDialog(self, fileTypeFilter, self.parent(), startdir=startdir) if dlg.exec() == QDialog.DialogCode.Accepted: @@ -2362,7 +2356,7 @@ @return flag indicating success (boolean) """ try: - from send2trash import send2trash as s2t + from send2trash import send2trash as s2t # __IGNORE_WARNING_I10__ except ImportError: s2t = os.remove @@ -2410,7 +2404,7 @@ dn = os.path.join(self.ppath, dn) try: try: - from send2trash import send2trash + from send2trash import send2trash # __IGNORE_WARNING_I10__ send2trash(dn) except ImportError: @@ -2453,11 +2447,13 @@ This method displays the new project dialog and initializes the project object with the data entered. """ + from eric7.VCS.CommandOptionsDialog import VcsCommandOptionsDialog + + from .PropertiesDialog import PropertiesDialog + if not self.checkDirty(): return - from .PropertiesDialog import PropertiesDialog - dlg = PropertiesDialog(self, True) if dlg.exec() == QDialog.DialogCode.Accepted: self.closeProject() @@ -2697,10 +2693,6 @@ else: vcores = False if vcores: - from eric7.VCS.CommandOptionsDialog import ( - VcsCommandOptionsDialog, - ) - codlg = VcsCommandOptionsDialog(self.vcs) if codlg.exec() == QDialog.DialogCode.Accepted: self.vcs.vcsSetOptions(codlg.getOptions()) @@ -2774,10 +2766,6 @@ else: vcores = False if vcores: - from eric7.VCS.CommandOptionsDialog import ( - VcsCommandOptionsDialog, - ) - codlg = VcsCommandOptionsDialog(self.vcs) if codlg.exec() == QDialog.DialogCode.Accepted: self.vcs.vcsSetOptions(codlg.getOptions()) @@ -2972,11 +2960,11 @@ """ Private slot to display the user specific properties dialog. """ + from .UserPropertiesDialog import UserPropertiesDialog + vcsSystem = self.pdata["VCS"] or None vcsSystemOverride = self.pudata["VCSOVERRIDE"] or None - from .UserPropertiesDialog import UserPropertiesDialog - dlg = UserPropertiesDialog(self) if dlg.exec() == QDialog.DialogCode.Accepted: dlg.storeData() @@ -5374,6 +5362,8 @@ (EricToolBarManager) @return tuple of the generated toolbars (tuple of two QToolBar) """ + from eric7 import VCS + tb = QToolBar(self.tr("Project"), self.ui) tb.setIconSize(Config.ToolBarIconSize) tb.setObjectName("ProjectToolbar") @@ -5392,8 +5382,6 @@ toolbarManager.addAction(self.propsAct, tb.windowTitle()) toolbarManager.addAction(self.userPropsAct, tb.windowTitle()) - from eric7 import VCS - vcstb = VCS.getBasicHelper(self).initBasicToolbar(self.ui, toolbarManager) return tb, vcstb @@ -5480,9 +5468,9 @@ """ Private slot to show the Find Project File dialog. """ + from .QuickFindFileDialog import QuickFindFileDialog + if self.__findProjectFileDialog is None: - from .QuickFindFileDialog import QuickFindFileDialog - self.__findProjectFileDialog = QuickFindFileDialog(self) self.__findProjectFileDialog.sourceFile.connect(self.sourceFile) self.__findProjectFileDialog.designerFile.connect(self.designerFile) @@ -5505,6 +5493,8 @@ @param onUserDemand flag indicating whether this method was requested by the user via a menu action (boolean) """ + from .AddFoundFilesDialog import AddFoundFilesDialog + autoInclude = Preferences.getProject("AutoIncludeNewFiles") recursiveSearch = Preferences.getProject("SearchNewFilesRecursively") newFiles = [] @@ -5605,8 +5595,6 @@ return # autoInclude is not set, show a dialog - from .AddFoundFilesDialog import AddFoundFilesDialog - dlg = AddFoundFilesDialog(newFiles, self.parent(), None) res = dlg.exec() @@ -5699,6 +5687,8 @@ (boolean) @return a reference to the vcs object """ + from eric7 import VCS + vcs = None forProject = True override = False @@ -5720,8 +5710,6 @@ override = True if vcsSystem is not None: - from eric7 import VCS - try: vcs = VCS.factory(vcsSystem) except ImportError: @@ -5778,8 +5766,6 @@ if forProject: if vcs is None: - from eric7 import VCS - self.vcsProjectHelper = VCS.getBasicHelper(self) self.vcsBasicHelper = True else: @@ -5880,13 +5866,13 @@ """ Private slot used to calculate some code metrics for the project files. """ + from eric7.DataViews.CodeMetricsDialog import CodeMetricsDialog + files = [ os.path.join(self.ppath, file) for file in self.pdata["SOURCES"] if file.endswith(".py") ] - from eric7.DataViews.CodeMetricsDialog import CodeMetricsDialog - self.codemetrics = CodeMetricsDialog() self.codemetrics.show() self.codemetrics.prepare(files) @@ -5896,6 +5882,8 @@ Private slot used to show the code coverage information for the project files. """ + from eric7.DataViews.PyCoverageDialog import PyCoverageDialog + fn = self.getMainScript(True) if fn is None: EricMessageBox.critical( @@ -5931,8 +5919,6 @@ for file in self.pdata["SOURCES"] if os.path.splitext(file)[1].startswith(".py") ] - from eric7.DataViews.PyCoverageDialog import PyCoverageDialog - self.codecoverage = PyCoverageDialog() self.codecoverage.show() self.codecoverage.start(fn, files) @@ -5941,6 +5927,8 @@ """ Private slot used to show the profiling information for the project. """ + from eric7.DataViews.PyProfileDialog import PyProfileDialog + fn = self.getMainScript(True) if fn is None: EricMessageBox.critical( @@ -5971,8 +5959,6 @@ else: return - from eric7.DataViews.PyProfileDialog import PyProfileDialog - self.profiledata = PyProfileDialog() self.profiledata.show() self.profiledata.start(fn) @@ -6008,6 +5994,8 @@ """ Public method to handle the application diagram context menu action. """ + from eric7.Graphics.UMLDialog import UMLDialog, UMLDialogType + res = EricMessageBox.yesNo( self.ui, self.tr("Application Diagram"), @@ -6015,8 +6003,6 @@ yesDefault=True, ) - from eric7.Graphics.UMLDialog import UMLDialog, UMLDialogType - self.applicationDiagram = UMLDialog( UMLDialogType.APPLICATION_DIAGRAM, self, self.parent(), noModules=not res ) @@ -6823,7 +6809,7 @@ """ Private slot to create a SBOM file of the project dependencies. """ - import CycloneDXInterface + import CycloneDXInterface # __IGNORE_WARNING_I102__ CycloneDXInterface.createCycloneDXFile("<project>")