eric7/Project/ProjectSourcesBrowser.py

branch
unittest
changeset 9092
043848f65726
parent 9072
8d3ae97ee666
child 9192
a763d57e23bc
diff -r 4231a14a89d7 -r 043848f65726 eric7/Project/ProjectSourcesBrowser.py
--- a/eric7/Project/ProjectSourcesBrowser.py	Mon May 23 16:50:04 2022 +0200
+++ b/eric7/Project/ProjectSourcesBrowser.py	Mon May 23 16:50:39 2022 +0200
@@ -755,33 +755,26 @@
         # a project coverage file
         fn = self.project.getMainScript(True)
         if fn is not None:
-            filenames = [os.path.splitext(f)[0]
-                         for f in [fn] + Utilities.getTestFileNames(fn)]
-            prEnable = any([
-                os.path.isfile("{0}.profile".format(f))
-                for f in filenames
-            ])
+            prEnable = (
+                self.project.isPy3Project() and
+                bool(Utilities.getProfileFileNames(fn))
+            )
             coEnable = (
                 self.project.isPy3Project() and
-                any([
-                    os.path.isfile("{0}.coverage".format(f))
-                    for f in filenames
-                ])
+                bool(Utilities.getCoverageFileNames(fn))
             )
         
         # now check the selected item
         itm = self.model().item(self.currentIndex())
         fn = itm.fileName()
         if fn is not None:
-            basename = os.path.splitext(fn)[0]
-            prEnable = (
-                prEnable or
-                os.path.isfile("{0}.profile".format(basename))
+            prEnable |= (
+                itm.isPython3File() and
+                bool(Utilities.getProfileFileNames(fn))
             )
-            coEnable = (
-                (coEnable or
-                 os.path.isfile("{0}.coverage".format(basename))) and
-                itm.isPython3File()
+            coEnable |= (
+                itm.isPython3File() and
+                bool(Utilities.getCoverageFileName(fn))
             )
         
         self.profileMenuAction.setEnabled(prEnable)
@@ -985,25 +978,17 @@
         fn = itm.fileName()
         pfn = self.project.getMainScript(True)
         
-        files = []
+        files = set()
         
         if pfn is not None:
-            for filename in [pfn] + Utilities.getTestFileNames(pfn):
-                basename = os.path.splitext(filename)[0]
-                f = "{0}.coverage".format(basename)
-                if os.path.isfile(f):
-                    files.append(f)
+            files |= set(Utilities.getCoverageFileNames(pfn))
         
         if fn is not None:
-            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 |= set(Utilities.getCoverageFileNames(fn))
         
-        if files:
+        if list(files):
             if len(files) > 1:
-                pfn, ok = QInputDialog.getItem(
+                cfn, ok = QInputDialog.getItem(
                     None,
                     self.tr("Code Coverage"),
                     self.tr("Please select a coverage file"),
@@ -1012,14 +997,14 @@
                 if not ok:
                     return
             else:
-                pfn = files[0]
+                cfn = files[0]
         else:
             return
         
         from DataViews.PyCoverageDialog import PyCoverageDialog
         self.codecoverage = PyCoverageDialog()
         self.codecoverage.show()
-        self.codecoverage.start(pfn, fn)
+        self.codecoverage.start(cfn, fn)
     
     def __showProfileData(self):
         """
@@ -1029,23 +1014,15 @@
         fn = itm.fileName()
         pfn = self.project.getMainScript(True)
         
-        files = []
+        files = set()
         
         if pfn is not None:
-            for filename in [pfn] + Utilities.getTestFileNames(pfn):
-                basename = os.path.splitext(filename)[0]
-                f = "{0}.profile".format(basename)
-                if os.path.isfile(f):
-                    files.append(f)
+            files |= set(Utilities.getProfileFileNames(pfn))
         
         if fn is not None:
-            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)
-                
-        if files:
+            files |= set(Utilities.getProfileFileNames(fn))
+        
+        if list(files):
             if len(files) > 1:
                 pfn, ok = QInputDialog.getItem(
                     None,

eric ide

mercurial