eric7/Project/Project.py

branch
unittest
changeset 9092
043848f65726
parent 9072
8d3ae97ee666
child 9117
c6afba2049cf
--- a/eric7/Project/Project.py	Mon May 23 16:50:04 2022 +0200
+++ b/eric7/Project/Project.py	Mon May 23 16:50:39 2022 +0200
@@ -3367,8 +3367,9 @@
         the project path.
         
         @param normalized flag indicating a normalized filename is wanted
-            (boolean)
-        @return filename of the projects main script (string)
+        @type bool
+        @return filename of the projects main script
+        @rtype str
         """
         if self.pdata["MAINSCRIPT"]:
             if normalized:
@@ -3376,15 +3377,16 @@
             else:
                 return self.pdata["MAINSCRIPT"]
         else:
-            return None
+            return ""
         
     def getSources(self, normalized=False):
         """
         Public method to return the source script files.
         
         @param normalized flag indicating a normalized filename is wanted
-            (boolean)
-        @return list of the projects scripts (list of string)
+        @type bool
+        @return list of the projects scripts
+        @rtype list of str
         """
         return self.getProjectFiles("SOURCES", normalized=normalized)
     
@@ -5068,14 +5070,7 @@
                     " current project. Aborting"))
             return
         
-        # determine name of coverage file to be used
-        files = []
-        for filename in [fn] + Utilities.getTestFileNames(fn):
-            basename = os.path.splitext(filename)[0]
-            f = "{0}.coverage".format(basename)
-            if os.path.isfile(f):
-                files.append(f)
-        
+        files = Utilities.getCoverageFileNames(fn)
         if files:
             if len(files) > 1:
                 fn, ok = QInputDialog.getItem(
@@ -5113,14 +5108,7 @@
                     " current project. Aborting"))
             return
         
-        # determine name of profile file to be used
-        files = []
-        for filename in [fn] + Utilities.getTestFileNames(fn):
-            basename = os.path.splitext(filename)[0]
-            f = "{0}.profile".format(basename)
-            if os.path.isfile(f):
-                files.append(f)
-        
+        files = Utilities.getProfileFileNames(fn)
         if files:
             if len(files) > 1:
                 fn, ok = QInputDialog.getItem(
@@ -5146,22 +5134,17 @@
         Private slot called before the show menu is shown.
         """
         fn = self.getMainScript(True)
-        if fn is not None:
-            filenames = [os.path.splitext(f)[0]
-                         for f in [fn] + Utilities.getTestFileNames(fn)]
-            self.codeProfileAct.setEnabled(any([
-                os.path.isfile("{0}.profile".format(f))
-                for f in filenames
-            ]))
-            self.codeCoverageAct.setEnabled(
-                self.isPy3Project() and any([
-                    os.path.isfile("{0}.coverage".format(f))
-                    for f in filenames
-                ])
-            )
-        else:
-            self.codeProfileAct.setEnabled(False)
-            self.codeCoverageAct.setEnabled(False)
+        if not fn:
+            fn = self.getProjectPath()
+        
+        self.codeProfileAct.setEnabled(
+            self.isPy3Project() and
+            bool(Utilities.getProfileFileName(fn))
+        )
+        self.codeCoverageAct.setEnabled(
+            self.isPy3Project() and
+            bool(Utilities.getCoverageFileNames(fn))
+        )
         
         self.showMenu.emit("Show", self.menuShow)
     

eric ide

mercurial