src/eric7/Project/Project.py

branch
eric7-maintenance
changeset 11019
27cd57e98461
parent 10892
409d010d7cae
parent 11006
a671918232f3
child 11063
bb05d1db9286
equal deleted inserted replaced
10947:c8df46dd566d 11019:27cd57e98461
1380 ) 1380 )
1381 else: 1381 else:
1382 fn1, _ext = os.path.splitext(os.path.basename(self.pfile)) 1382 fn1, _ext = os.path.splitext(os.path.basename(self.pfile))
1383 fn = os.path.join(self.getProjectManagementDir(), f"{fn1}{indicator}.esj") 1383 fn = os.path.join(self.getProjectManagementDir(), f"{fn1}{indicator}.esj")
1384 1384
1385 self.__sessionFile.writeFile(fn) 1385 self.__sessionFile.writeFile(fn, withServer=False)
1386 1386
1387 def __deleteSession(self): 1387 def __deleteSession(self):
1388 """ 1388 """
1389 Private method to delete the session file. 1389 Private method to delete the session file.
1390 """ 1390 """
1644 Private slot to display the debugger properties dialog. 1644 Private slot to display the debugger properties dialog.
1645 """ 1645 """
1646 from .DebuggerPropertiesDialog import DebuggerPropertiesDialog 1646 from .DebuggerPropertiesDialog import DebuggerPropertiesDialog
1647 1647
1648 dlg = DebuggerPropertiesDialog( 1648 dlg = DebuggerPropertiesDialog(
1649 self, isRemote=FileSystemUtilities.isRemoteFileName(self.ppath) 1649 self,
1650 isRemote=FileSystemUtilities.isRemoteFileName(self.ppath),
1651 parent=self.ui,
1650 ) 1652 )
1651 if dlg.exec() == QDialog.DialogCode.Accepted: 1653 if dlg.exec() == QDialog.DialogCode.Accepted:
1652 dlg.storeData() 1654 dlg.storeData()
1653 1655
1654 def getDebugProperty(self, key): 1656 def getDebugProperty(self, key):
1774 self.tr("Add Language"), 1776 self.tr("Add Language"),
1775 self.tr("You have to specify a translation pattern first."), 1777 self.tr("You have to specify a translation pattern first."),
1776 ) 1778 )
1777 return 1779 return
1778 1780
1779 dlg = AddLanguageDialog(self.parent()) 1781 dlg = AddLanguageDialog(parent=self.parent())
1780 if dlg.exec() == QDialog.DialogCode.Accepted: 1782 if dlg.exec() == QDialog.DialogCode.Accepted:
1781 lang = dlg.getSelectedLanguage() 1783 lang = dlg.getSelectedLanguage()
1782 if self.__pdata["PROJECTTYPE"] in [ 1784 if self.__pdata["PROJECTTYPE"] in [
1783 "PyQt5", 1785 "PyQt5",
1784 "PyQt5C", 1786 "PyQt5C",
2037 from .AddFileDialog import AddFileDialog 2039 from .AddFileDialog import AddFileDialog
2038 2040
2039 if not startdir: 2041 if not startdir:
2040 startdir = self.ppath 2042 startdir = self.ppath
2041 2043
2042 dlg = AddFileDialog(self, self.parent(), fileTypeFilter, startdir=startdir) 2044 dlg = AddFileDialog(
2045 self, parent=self.parent(), fileTypeFilter=fileTypeFilter, startdir=startdir
2046 )
2043 if dlg.exec() == QDialog.DialogCode.Accepted: 2047 if dlg.exec() == QDialog.DialogCode.Accepted:
2044 fnames, target, isSource = dlg.getData() 2048 fnames, target, isSource = dlg.getData()
2045 if target != "": 2049 if target != "":
2046 isRemote = FileSystemUtilities.isRemoteFileName(target) 2050 isRemote = FileSystemUtilities.isRemoteFileName(target)
2047 for fn in fnames: 2051 for fn in fnames:
2277 from .AddDirectoryDialog import AddDirectoryDialog 2281 from .AddDirectoryDialog import AddDirectoryDialog
2278 2282
2279 if not startdir: 2283 if not startdir:
2280 startdir = self.ppath 2284 startdir = self.ppath
2281 2285
2282 dlg = AddDirectoryDialog(self, fileTypeFilter, self.parent(), startdir=startdir) 2286 dlg = AddDirectoryDialog(
2287 self, fileTypeFilter, parent=self.parent(), startdir=startdir
2288 )
2283 if dlg.exec() == QDialog.DialogCode.Accepted: 2289 if dlg.exec() == QDialog.DialogCode.Accepted:
2284 filetype, source, target, recursive = dlg.getData() 2290 filetype, source, target, recursive = dlg.getData()
2285 if target == "": 2291 if target == "":
2286 EricMessageBox.critical( 2292 EricMessageBox.critical(
2287 self.ui, 2293 self.ui,
2751 if not self.checkDirty(): 2757 if not self.checkDirty():
2752 return 2758 return
2753 2759
2754 isRemote = self.__remoteServer.isServerConnected() 2760 isRemote = self.__remoteServer.isServerConnected()
2755 2761
2756 dlg = PropertiesDialog(self, new=True, isRemote=isRemote) 2762 dlg = PropertiesDialog(self, new=True, isRemote=isRemote, parent=self.ui)
2757 if dlg.exec() == QDialog.DialogCode.Accepted: 2763 if dlg.exec() == QDialog.DialogCode.Accepted:
2758 self.closeProject() 2764 self.closeProject()
2759 2765
2760 # reset the auto save flag 2766 # reset the auto save flag
2761 autoSaveProject = Preferences.getProject("AutoSaveProject") 2767 autoSaveProject = Preferences.getProject("AutoSaveProject")
3091 ), 3097 ),
3092 ) 3098 )
3093 else: 3099 else:
3094 vcores = False 3100 vcores = False
3095 if vcores: 3101 if vcores:
3096 codlg = VcsCommandOptionsDialog(self.vcs) 3102 codlg = VcsCommandOptionsDialog(
3103 self.vcs, parent=self.ui
3104 )
3097 if codlg.exec() == QDialog.DialogCode.Accepted: 3105 if codlg.exec() == QDialog.DialogCode.Accepted:
3098 self.vcs.vcsSetOptions(codlg.getOptions()) 3106 self.vcs.vcsSetOptions(codlg.getOptions())
3099 # add project file to repository 3107 # add project file to repository
3100 if res == 0: 3108 if res == 0:
3101 apres = EricMessageBox.yesNo( 3109 apres = EricMessageBox.yesNo(
3147 self.__pdata["VCS"] = "None" 3155 self.__pdata["VCS"] = "None"
3148 else: 3156 else:
3149 self.__pdata["VCS"] = "None" 3157 self.__pdata["VCS"] = "None"
3150 self.vcs = self.initVCS() 3158 self.vcs = self.initVCS()
3151 if self.vcs is not None: 3159 if self.vcs is not None:
3152 vcsdlg = self.vcs.vcsOptionsDialog(self, self.name) 3160 vcsdlg = self.vcs.vcsOptionsDialog(self, self.name, parent=self.ui)
3153 if vcsdlg.exec() == QDialog.DialogCode.Accepted: 3161 if vcsdlg.exec() == QDialog.DialogCode.Accepted:
3154 vcsDataDict = vcsdlg.getData() 3162 vcsDataDict = vcsdlg.getData()
3155 else: 3163 else:
3156 self.__pdata["VCS"] = "None" 3164 self.__pdata["VCS"] = "None"
3157 self.vcs = self.initVCS() 3165 self.vcs = self.initVCS()
3168 ), 3176 ),
3169 ) 3177 )
3170 else: 3178 else:
3171 vcores = False 3179 vcores = False
3172 if vcores: 3180 if vcores:
3173 codlg = VcsCommandOptionsDialog(self.vcs) 3181 codlg = VcsCommandOptionsDialog(self.vcs, parent=self.ui)
3174 if codlg.exec() == QDialog.DialogCode.Accepted: 3182 if codlg.exec() == QDialog.DialogCode.Accepted:
3175 self.vcs.vcsSetOptions(codlg.getOptions()) 3183 self.vcs.vcsSetOptions(codlg.getOptions())
3176 3184
3177 # create the project in the VCS 3185 # create the project in the VCS
3178 self.vcs.vcsSetDataFromDict(vcsDataDict) 3186 self.vcs.vcsSetDataFromDict(vcsDataDict)
3398 Private slot to display the properties dialog. 3406 Private slot to display the properties dialog.
3399 """ 3407 """
3400 from .PropertiesDialog import PropertiesDialog 3408 from .PropertiesDialog import PropertiesDialog
3401 3409
3402 isRemote = FileSystemUtilities.isRemoteFileName(self.ppath) 3410 isRemote = FileSystemUtilities.isRemoteFileName(self.ppath)
3403 dlg = PropertiesDialog(self, new=False, isRemote=isRemote) 3411 dlg = PropertiesDialog(self, new=False, isRemote=isRemote, parent=self.ui)
3404 if dlg.exec() == QDialog.DialogCode.Accepted: 3412 if dlg.exec() == QDialog.DialogCode.Accepted:
3405 fileTypesDict = copy.copy(self.__pdata["FILETYPES"]) 3413 fileTypesDict = copy.copy(self.__pdata["FILETYPES"])
3406 dlg.storeData() 3414 dlg.storeData()
3407 self.setDirty(True) 3415 self.setDirty(True)
3408 if self.__pdata["MAINSCRIPT"]: 3416 if self.__pdata["MAINSCRIPT"]:
3517 from .UserPropertiesDialog import UserPropertiesDialog 3525 from .UserPropertiesDialog import UserPropertiesDialog
3518 3526
3519 vcsSystem = self.__pdata["VCS"] or None 3527 vcsSystem = self.__pdata["VCS"] or None
3520 vcsSystemOverride = self.pudata["VCSOVERRIDE"] or None 3528 vcsSystemOverride = self.pudata["VCSOVERRIDE"] or None
3521 3529
3522 dlg = UserPropertiesDialog(self) 3530 dlg = UserPropertiesDialog(self, parent=self.ui)
3523 if dlg.exec() == QDialog.DialogCode.Accepted: 3531 if dlg.exec() == QDialog.DialogCode.Accepted:
3524 dlg.storeData() 3532 dlg.storeData()
3525 3533
3526 if ( 3534 if (
3527 (self.__pdata["VCS"] and self.__pdata["VCS"] != vcsSystem) 3535 (self.__pdata["VCS"] and self.__pdata["VCS"] != vcsSystem)
3555 """ 3563 """
3556 Private slot to display the filetype association dialog. 3564 Private slot to display the filetype association dialog.
3557 """ 3565 """
3558 from .FiletypeAssociationDialog import FiletypeAssociationDialog 3566 from .FiletypeAssociationDialog import FiletypeAssociationDialog
3559 3567
3560 dlg = FiletypeAssociationDialog(self, self.getProjectData(dataKey="FILETYPES")) 3568 dlg = FiletypeAssociationDialog(
3569 self, self.getProjectData(dataKey="FILETYPES"), parent=self.ui
3570 )
3561 if dlg.exec() == QDialog.DialogCode.Accepted: 3571 if dlg.exec() == QDialog.DialogCode.Accepted:
3562 fileTypes = dlg.getData() 3572 fileTypes = dlg.getData()
3563 self.setProjectData(fileTypes, dataKey="FILETYPES") 3573 self.setProjectData(fileTypes, dataKey="FILETYPES")
3564 self.setDirty(True) 3574 self.setDirty(True)
3565 self.__reorganizeFiles() 3575 self.__reorganizeFiles()
3585 """ 3595 """
3586 Private slot to display the lexer association dialog. 3596 Private slot to display the lexer association dialog.
3587 """ 3597 """
3588 from .LexerAssociationDialog import LexerAssociationDialog 3598 from .LexerAssociationDialog import LexerAssociationDialog
3589 3599
3590 dlg = LexerAssociationDialog(self) 3600 dlg = LexerAssociationDialog(self, parent=self.ui)
3591 if dlg.exec() == QDialog.DialogCode.Accepted: 3601 if dlg.exec() == QDialog.DialogCode.Accepted:
3592 dlg.transferData() 3602 dlg.transferData()
3593 self.setDirty(True) 3603 self.setDirty(True)
3594 self.lexerAssociationsChanged.emit() 3604 self.lexerAssociationsChanged.emit()
3595 3605
3819 ericApp().getObject("TaskViewer").regenerateProjectTasks(quiet=True) 3829 ericApp().getObject("TaskViewer").regenerateProjectTasks(quiet=True)
3820 3830
3821 if restoreSession: 3831 if restoreSession:
3822 # open the main script 3832 # open the main script
3823 if self.__pdata["MAINSCRIPT"]: 3833 if self.__pdata["MAINSCRIPT"]:
3824 if not os.path.isabs(self.__pdata["MAINSCRIPT"]): 3834 ms = self.getAbsolutePath(self.__pdata["MAINSCRIPT"])
3825 ms = os.path.join(self.ppath, self.__pdata["MAINSCRIPT"])
3826 else:
3827 ms = self.__pdata["MAINSCRIPT"]
3828 self.sourceFile.emit(ms) 3835 self.sourceFile.emit(ms)
3829 3836
3830 # open a project session file being quiet about errors 3837 # open a project session file being quiet about errors
3831 if reopen: 3838 if reopen:
3832 self.__readSession(quiet=True, indicator="_tmp") 3839 self.__readSession(quiet=True, indicator="_tmp")
7038 dlg = EricListSelectionDialog( 7045 dlg = EricListSelectionDialog(
7039 sorted(pkglists), 7046 sorted(pkglists),
7040 title=self.tr("Create Plugin Archive"), 7047 title=self.tr("Create Plugin Archive"),
7041 message=self.tr("Select package lists:"), 7048 message=self.tr("Select package lists:"),
7042 checkBoxSelection=True, 7049 checkBoxSelection=True,
7050 parent=self.ui,
7043 ) 7051 )
7044 if dlg.exec() == QDialog.DialogCode.Accepted: 7052 if dlg.exec() == QDialog.DialogCode.Accepted:
7045 selectedLists = [ 7053 selectedLists = [
7046 os.path.join(self.ppath, s) for s in dlg.getSelection() 7054 os.path.join(self.ppath, s) for s in dlg.getSelection()
7047 ] 7055 ]
7628 """ 7636 """
7629 Private slot to create a SBOM file of the project dependencies. 7637 Private slot to create a SBOM file of the project dependencies.
7630 """ 7638 """
7631 from eric7 import CycloneDXInterface 7639 from eric7 import CycloneDXInterface
7632 7640
7633 CycloneDXInterface.createCycloneDXFile("<project>") 7641 CycloneDXInterface.createCycloneDXFile("<project>", parent=self.ui)
7634 7642
7635 ######################################################################### 7643 #########################################################################
7636 ## Below are methods implementing the 'Code Formatting' support 7644 ## Below are methods implementing the 'Code Formatting' support
7637 ######################################################################### 7645 #########################################################################
7638 7646
7662 BlackConfigurationDialog, 7670 BlackConfigurationDialog,
7663 ) 7671 )
7664 from eric7.CodeFormatting.BlackFormattingDialog import BlackFormattingDialog 7672 from eric7.CodeFormatting.BlackFormattingDialog import BlackFormattingDialog
7665 7673
7666 if ericApp().getObject("ViewManager").checkAllDirty(): 7674 if ericApp().getObject("ViewManager").checkAllDirty():
7667 dlg = BlackConfigurationDialog(withProject=True) 7675 dlg = BlackConfigurationDialog(withProject=True, parent=self.ui)
7668 if dlg.exec() == QDialog.DialogCode.Accepted: 7676 if dlg.exec() == QDialog.DialogCode.Accepted:
7669 config = dlg.getConfiguration(saveToProject=True) 7677 config = dlg.getConfiguration(saveToProject=True)
7670 7678
7671 formattingDialog = BlackFormattingDialog( 7679 formattingDialog = BlackFormattingDialog(
7672 config, 7680 config,
7673 self.getProjectFiles("SOURCES", normalized=True), 7681 self.getProjectFiles("SOURCES", normalized=True),
7674 project=self, 7682 project=self,
7675 action=action, 7683 action=action,
7684 parent=self.ui,
7676 ) 7685 )
7677 formattingDialog.exec() 7686 formattingDialog.exec()
7678 7687
7679 @pyqtSlot() 7688 @pyqtSlot()
7680 def __configureBlack(self): 7689 def __configureBlack(self):
7684 """ 7693 """
7685 from eric7.CodeFormatting.BlackConfigurationDialog import ( 7694 from eric7.CodeFormatting.BlackConfigurationDialog import (
7686 BlackConfigurationDialog, 7695 BlackConfigurationDialog,
7687 ) 7696 )
7688 7697
7689 dlg = BlackConfigurationDialog(withProject=True, onlyProject=True) 7698 dlg = BlackConfigurationDialog(
7699 withProject=True, onlyProject=True, parent=self.ui
7700 )
7690 if dlg.exec() == QDialog.DialogCode.Accepted: 7701 if dlg.exec() == QDialog.DialogCode.Accepted:
7691 dlg.getConfiguration(saveToProject=True) 7702 dlg.getConfiguration(saveToProject=True)
7692 # The data is saved to the project as a side effect. 7703 # The data is saved to the project as a side effect.
7693 7704
7694 def __performImportSortingWithIsort(self, action): 7705 def __performImportSortingWithIsort(self, action):
7712 IsortConfigurationDialog, 7723 IsortConfigurationDialog,
7713 ) 7724 )
7714 from eric7.CodeFormatting.IsortFormattingDialog import IsortFormattingDialog 7725 from eric7.CodeFormatting.IsortFormattingDialog import IsortFormattingDialog
7715 7726
7716 if ericApp().getObject("ViewManager").checkAllDirty(): 7727 if ericApp().getObject("ViewManager").checkAllDirty():
7717 dlg = IsortConfigurationDialog(withProject=True) 7728 dlg = IsortConfigurationDialog(withProject=True, parent=self.ui)
7718 if dlg.exec() == QDialog.DialogCode.Accepted: 7729 if dlg.exec() == QDialog.DialogCode.Accepted:
7719 config = dlg.getConfiguration(saveToProject=True) 7730 config = dlg.getConfiguration(saveToProject=True)
7720 7731
7721 isortDialog = IsortFormattingDialog( 7732 isortDialog = IsortFormattingDialog(
7722 config, 7733 config,
7723 self.getProjectFiles("SOURCES", normalized=True), 7734 self.getProjectFiles("SOURCES", normalized=True),
7724 project=self, 7735 project=self,
7725 action=action, 7736 action=action,
7737 parent=self.ui,
7726 ) 7738 )
7727 isortDialog.exec() 7739 isortDialog.exec()
7728 7740
7729 @pyqtSlot() 7741 @pyqtSlot()
7730 def __configureIsort(self): 7742 def __configureIsort(self):
7734 """ 7746 """
7735 from eric7.CodeFormatting.IsortConfigurationDialog import ( 7747 from eric7.CodeFormatting.IsortConfigurationDialog import (
7736 IsortConfigurationDialog, 7748 IsortConfigurationDialog,
7737 ) 7749 )
7738 7750
7739 dlg = IsortConfigurationDialog(withProject=True, onlyProject=True) 7751 dlg = IsortConfigurationDialog(
7752 withProject=True, onlyProject=True, parent=self.ui
7753 )
7740 if dlg.exec() == QDialog.DialogCode.Accepted: 7754 if dlg.exec() == QDialog.DialogCode.Accepted:
7741 dlg.getConfiguration(saveToProject=True) 7755 dlg.getConfiguration(saveToProject=True)
7742 # The data is saved to the project as a side effect. 7756 # The data is saved to the project as a side effect.
7743 7757
7744 ######################################################################### 7758 #########################################################################
7823 ) 7837 )
7824 7838
7825 environmentPath = self.__findEmbeddedEnvironment() 7839 environmentPath = self.__findEmbeddedEnvironment()
7826 if force or upgrade or not environmentPath: 7840 if force or upgrade or not environmentPath:
7827 dlg = ProjectVenvCreationParametersDialog( 7841 dlg = ProjectVenvCreationParametersDialog(
7828 withSystemSitePackages=self.__venvConfiguration["system_site_packages"] 7842 withSystemSitePackages=self.__venvConfiguration["system_site_packages"],
7843 parent=self.ui,
7829 ) 7844 )
7830 if dlg.exec() != QDialog.DialogCode.Accepted: 7845 if dlg.exec() != QDialog.DialogCode.Accepted:
7831 # user canceled the environment creation 7846 # user canceled the environment creation
7832 self.__setEmbeddedEnvironmentProjectConfig(False) 7847 self.__setEmbeddedEnvironmentProjectConfig(False)
7833 return 7848 return
7850 if os.path.exists(os.path.join(self.getProjectPath(), ".venv")): 7865 if os.path.exists(os.path.join(self.getProjectPath(), ".venv")):
7851 args.append("--clear") 7866 args.append("--clear")
7852 if withSystemSitePackages: 7867 if withSystemSitePackages:
7853 args.append("--system-site-packages") 7868 args.append("--system-site-packages")
7854 args.append(configuration["targetDirectory"]) 7869 args.append(configuration["targetDirectory"])
7855 dia = VirtualenvExecDialog(configuration, None) 7870 dia = VirtualenvExecDialog(configuration, None, parent=self.ui)
7856 dia.show() 7871 dia.show()
7857 dia.start(args) 7872 dia.start(args)
7858 dia.exec() 7873 dia.exec()
7859 7874
7860 self.__venvConfiguration["system_site_packages"] = withSystemSitePackages 7875 self.__venvConfiguration["system_site_packages"] = withSystemSitePackages
7895 dlg = ProjectVenvConfigurationDialog( 7910 dlg = ProjectVenvConfigurationDialog(
7896 self.__venvConfiguration["name"], 7911 self.__venvConfiguration["name"],
7897 environmentPath, 7912 environmentPath,
7898 self.__venvConfiguration["interpreter"], 7913 self.__venvConfiguration["interpreter"],
7899 self.__venvConfiguration["exec_path"], 7914 self.__venvConfiguration["exec_path"],
7915 parent=self.ui,
7900 ) 7916 )
7901 if dlg.exec() == QDialog.DialogCode.Accepted: 7917 if dlg.exec() == QDialog.DialogCode.Accepted:
7902 ( 7918 (
7903 self.__venvConfiguration["interpreter"], 7919 self.__venvConfiguration["interpreter"],
7904 self.__venvConfiguration["exec_path"], 7920 self.__venvConfiguration["exec_path"],
8007 ) 8023 )
8008 if not connected and FileSystemUtilities.isRemoteFileName(self.ppath): 8024 if not connected and FileSystemUtilities.isRemoteFileName(self.ppath):
8009 self.closeProject(noSave=True) 8025 self.closeProject(noSave=True)
8010 8026
8011 @pyqtSlot() 8027 @pyqtSlot()
8028 def remoteConnectionAboutToDisconnect(self):
8029 """
8030 Public slot to handle the imminent disconnect from an 'eric-ide' server.
8031 """
8032 if FileSystemUtilities.isRemoteFileName(self.ppath):
8033 self.closeProject()
8034
8035 @pyqtSlot()
8012 def __openRemoteProject(self): 8036 def __openRemoteProject(self):
8013 """ 8037 """
8014 Private slot to open a project of an 'eric-ide' server. 8038 Private slot to open a project of an 'eric-ide' server.
8015 """ 8039 """
8016 fn = EricServerFileDialog.getOpenFileName( 8040 fn = EricServerFileDialog.getOpenFileName(

eric ide

mercurial