37 import UI.PixmapCache |
37 import UI.PixmapCache |
38 from UI.NotificationWidget import NotificationTypes |
38 from UI.NotificationWidget import NotificationTypes |
39 |
39 |
40 from EricGui.EricAction import EricAction, createActionGroup |
40 from EricGui.EricAction import EricAction, createActionGroup |
41 |
41 |
|
42 import Globals |
42 import Preferences |
43 import Preferences |
43 import Utilities |
44 import Utilities |
44 |
45 |
45 from .ProjectFile import ProjectFile |
46 from .ProjectFile import ProjectFile |
46 from .UserProjectFile import UserProjectFile |
47 from .UserProjectFile import UserProjectFile |
3359 |
3361 |
3360 def getMainScript(self, normalized=False): |
3362 def getMainScript(self, normalized=False): |
3361 """ |
3363 """ |
3362 Public method to return the main script filename. |
3364 Public method to return the main script filename. |
3363 |
3365 |
|
3366 The normalized name is the name of the main script prepended with |
|
3367 the project path. |
|
3368 |
3364 @param normalized flag indicating a normalized filename is wanted |
3369 @param normalized flag indicating a normalized filename is wanted |
3365 (boolean) |
3370 @type bool |
3366 @return filename of the projects main script (string) |
3371 @return filename of the projects main script |
|
3372 @rtype str |
3367 """ |
3373 """ |
3368 if self.pdata["MAINSCRIPT"]: |
3374 if self.pdata["MAINSCRIPT"]: |
3369 if normalized: |
3375 if normalized: |
3370 return os.path.join(self.ppath, self.pdata["MAINSCRIPT"]) |
3376 return os.path.join(self.ppath, self.pdata["MAINSCRIPT"]) |
3371 else: |
3377 else: |
3372 return self.pdata["MAINSCRIPT"] |
3378 return self.pdata["MAINSCRIPT"] |
3373 else: |
3379 else: |
3374 return None |
3380 return "" |
3375 |
3381 |
3376 def getSources(self, normalized=False): |
3382 def getSources(self, normalized=False): |
3377 """ |
3383 """ |
3378 Public method to return the source script files. |
3384 Public method to return the source script files. |
3379 |
3385 |
3380 @param normalized flag indicating a normalized filename is wanted |
3386 @param normalized flag indicating a normalized filename is wanted |
3381 (boolean) |
3387 @type bool |
3382 @return list of the projects scripts (list of string) |
3388 @return list of the projects scripts |
|
3389 @rtype list of str |
3383 """ |
3390 """ |
3384 return self.getProjectFiles("SOURCES", normalized=normalized) |
3391 return self.getProjectFiles("SOURCES", normalized=normalized) |
3385 |
3392 |
3386 def getProjectFiles(self, fileType, normalized=False): |
3393 def getProjectFiles(self, fileType, normalized=False): |
3387 """ |
3394 """ |
3701 |
3708 |
3702 @return project description |
3709 @return project description |
3703 @rtype str |
3710 @rtype str |
3704 """ |
3711 """ |
3705 return self.pdata["DESCRIPTION"] |
3712 return self.pdata["DESCRIPTION"] |
|
3713 |
|
3714 def getProjectVenv(self, resolveDebugger=True): |
|
3715 """ |
|
3716 Public method to get the name of the virtual environment used by the |
|
3717 project. |
|
3718 |
|
3719 @param resolveDebugger flag indicating to resolve the virtual |
|
3720 environment name via the debugger settings if none was configured |
|
3721 @type bool |
|
3722 @return name of the project's virtual environment |
|
3723 @rtype str |
|
3724 """ |
|
3725 venvName = self.getDebugProperty("VIRTUALENV") |
|
3726 if ( |
|
3727 not venvName and |
|
3728 resolveDebugger and |
|
3729 self.getProjectLanguage() in ("Python3", "MicroPython", "Cython") |
|
3730 ): |
|
3731 venvName = Preferences.getDebugger("Python3VirtualEnv") |
|
3732 |
|
3733 return venvName |
|
3734 |
|
3735 def getProjectInterpreter(self, resolveGlobal=True): |
|
3736 """ |
|
3737 Public method to get the path of the interpreter used by the project. |
|
3738 |
|
3739 @param resolveGlobal flag indicating to resolve the interpreter using |
|
3740 the global interpreter if no project of debugger specific |
|
3741 environment was configured |
|
3742 @type bool |
|
3743 @return path of the project's interpreter |
|
3744 @rtype str |
|
3745 """ |
|
3746 interpreter = "" |
|
3747 venvName = self.getProjectVenv() |
|
3748 if venvName: |
|
3749 interpreter = ( |
|
3750 ericApp().getObject("VirtualEnvManager") |
|
3751 .getVirtualenvInterpreter(venvName) |
|
3752 ) |
|
3753 if not interpreter and resolveGlobal: |
|
3754 interpreter = Globals.getPythonExecutable() |
|
3755 |
|
3756 return interpreter |
|
3757 |
|
3758 def getProjectExecPath(self): |
|
3759 """ |
|
3760 Public method to get the executable search path prefix of the project. |
|
3761 |
|
3762 @return executable search path prefix |
|
3763 @rtype str |
|
3764 """ |
|
3765 execPath = "" |
|
3766 venvName = self.getProjectVenv() |
|
3767 if venvName: |
|
3768 execPath = ( |
|
3769 ericApp().getObject("VirtualEnvManager") |
|
3770 .getVirtualenvExecPath(venvName) |
|
3771 ) |
|
3772 |
|
3773 return execPath |
|
3774 |
|
3775 def getProjectTestingFramework(self): |
|
3776 """ |
|
3777 Public method to get the testing framework name of the project. |
|
3778 |
|
3779 @return testing framework name of the project |
|
3780 @rtype str |
|
3781 """ |
|
3782 try: |
|
3783 return self.pdata["TESTING_FRAMEWORK"] |
|
3784 except KeyError: |
|
3785 return "" |
3706 |
3786 |
3707 def __isInPdata(self, fn): |
3787 def __isInPdata(self, fn): |
3708 """ |
3788 """ |
3709 Private method used to check, if the passed in filename is project |
3789 Private method used to check, if the passed in filename is project |
3710 controlled.. |
3790 controlled.. |
4988 self.tr( |
5068 self.tr( |
4989 "There is no main script defined for the" |
5069 "There is no main script defined for the" |
4990 " current project. Aborting")) |
5070 " current project. Aborting")) |
4991 return |
5071 return |
4992 |
5072 |
4993 tfn = Utilities.getTestFileName(fn) |
5073 files = Utilities.getCoverageFileNames(fn) |
4994 basename = os.path.splitext(fn)[0] |
|
4995 tbasename = os.path.splitext(tfn)[0] |
|
4996 |
|
4997 # determine name of coverage file to be used |
|
4998 files = [] |
|
4999 f = "{0}.coverage".format(basename) |
|
5000 tf = "{0}.coverage".format(tbasename) |
|
5001 if os.path.isfile(f): |
|
5002 files.append(f) |
|
5003 if os.path.isfile(tf): |
|
5004 files.append(tf) |
|
5005 |
|
5006 if files: |
5074 if files: |
5007 if len(files) > 1: |
5075 if len(files) > 1: |
5008 fn, ok = QInputDialog.getItem( |
5076 fn, ok = QInputDialog.getItem( |
5009 None, |
5077 None, |
5010 self.tr("Code Coverage"), |
5078 self.tr("Code Coverage"), |
5038 self.tr( |
5106 self.tr( |
5039 "There is no main script defined for the" |
5107 "There is no main script defined for the" |
5040 " current project. Aborting")) |
5108 " current project. Aborting")) |
5041 return |
5109 return |
5042 |
5110 |
5043 tfn = Utilities.getTestFileName(fn) |
5111 files = Utilities.getProfileFileNames(fn) |
5044 basename = os.path.splitext(fn)[0] |
|
5045 tbasename = os.path.splitext(tfn)[0] |
|
5046 |
|
5047 # determine name of profile file to be used |
|
5048 files = [] |
|
5049 f = "{0}.profile".format(basename) |
|
5050 tf = "{0}.profile".format(tbasename) |
|
5051 if os.path.isfile(f): |
|
5052 files.append(f) |
|
5053 if os.path.isfile(tf): |
|
5054 files.append(tf) |
|
5055 |
|
5056 if files: |
5112 if files: |
5057 if len(files) > 1: |
5113 if len(files) > 1: |
5058 fn, ok = QInputDialog.getItem( |
5114 fn, ok = QInputDialog.getItem( |
5059 None, |
5115 None, |
5060 self.tr("Profile Data"), |
5116 self.tr("Profile Data"), |
5076 def __showContextMenuShow(self): |
5132 def __showContextMenuShow(self): |
5077 """ |
5133 """ |
5078 Private slot called before the show menu is shown. |
5134 Private slot called before the show menu is shown. |
5079 """ |
5135 """ |
5080 fn = self.getMainScript(True) |
5136 fn = self.getMainScript(True) |
5081 if fn is not None: |
5137 if not fn: |
5082 tfn = Utilities.getTestFileName(fn) |
5138 fn = self.getProjectPath() |
5083 basename = os.path.splitext(fn)[0] |
5139 |
5084 tbasename = os.path.splitext(tfn)[0] |
5140 self.codeProfileAct.setEnabled( |
5085 self.codeProfileAct.setEnabled( |
5141 self.isPy3Project() and |
5086 os.path.isfile("{0}.profile".format(basename)) or |
5142 bool(Utilities.getProfileFileName(fn)) |
5087 os.path.isfile("{0}.profile".format(tbasename))) |
5143 ) |
5088 self.codeCoverageAct.setEnabled( |
5144 self.codeCoverageAct.setEnabled( |
5089 self.isPy3Project() and |
5145 self.isPy3Project() and |
5090 (os.path.isfile("{0}.coverage".format(basename)) or |
5146 bool(Utilities.getCoverageFileNames(fn)) |
5091 os.path.isfile("{0}.coverage".format(tbasename)))) |
5147 ) |
5092 else: |
|
5093 self.codeProfileAct.setEnabled(False) |
|
5094 self.codeCoverageAct.setEnabled(False) |
|
5095 |
5148 |
5096 self.showMenu.emit("Show", self.menuShow) |
5149 self.showMenu.emit("Show", self.menuShow) |
5097 |
5150 |
5098 ######################################################################### |
5151 ######################################################################### |
5099 ## Below is the interface to the diagrams |
5152 ## Below is the interface to the diagrams |