Corrected a few issues related to showing the coverage context menu items. 5_1_x

Sat, 17 Dec 2011 15:19:45 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 17 Dec 2011 15:19:45 +0100
branch
5_1_x
changeset 1493
876e068d632d
parent 1489
e647aa92e0ea
child 1494
59b2003e2a06

Corrected a few issues related to showing the coverage context menu items.
(transplanted from 985c5abc8226c364c2e1f43f175e24fb205fe985)

Project/Project.py file | annotate | diff | comparison | revisions
Project/ProjectSourcesBrowser.py file | annotate | diff | comparison | revisions
PyUnit/UnittestDialog.py file | annotate | diff | comparison | revisions
QScintilla/Editor.py file | annotate | diff | comparison | revisions
--- a/Project/Project.py	Sat Dec 10 18:01:16 2011 +0100
+++ b/Project/Project.py	Sat Dec 17 15:19:45 2011 +0100
@@ -2646,6 +2646,30 @@
         """
         return self.pdata["PROGLANGUAGE"][0]
         
+    def isPy3Project(self):
+        """
+        Public method to check, if this project is a Python3 project.
+        
+        @return flag indicating a Python3 project (boolean)
+        """
+        return self.pdata["PROGLANGUAGE"][0] == "Python3"
+        
+    def isPy2Project(self):
+        """
+        Public method to check, if this project is a Python2 project.
+        
+        @return flag indicating a Python2 project (boolean)
+        """
+        return self.pdata["PROGLANGUAGE"][0] in ["Python", "Python2"]
+        
+    def isRubyProject(self):
+        """
+        Public method to check, if this project is a Ruby project.
+        
+        @return flag indicating a Ruby project (boolean)
+        """
+        return self.pdata["PROGLANGUAGE"][0] == "Ruby"
+        
     def getProjectSpellLanguage(self):
         """
         Public method to get the project's programming language.
@@ -3870,7 +3894,7 @@
                 os.path.isfile("{0}.profile".format(basename)) or \
                 os.path.isfile("{0}.profile".format(tbasename)))
             self.codeCoverageAct.setEnabled(
-                self.pdata["PROGLANGUAGE"][0] == "Python3" and \
+                self.isPy3Project() and \
                 (os.path.isfile("{0}.coverage".format(basename)) or \
                  os.path.isfile("{0}.coverage".format(tbasename))))
         else:
--- a/Project/ProjectSourcesBrowser.py	Sat Dec 10 18:01:16 2011 +0100
+++ b/Project/ProjectSourcesBrowser.py	Sat Dec 17 15:19:45 2011 +0100
@@ -497,9 +497,10 @@
             prEnable = prEnable or \
                 os.path.isfile("{0}.profile".format(basename)) or \
                 os.path.isfile("{0}.profile".format(tbasename))
-            coEnable = coEnable or \
+            coEnable = (coEnable or \
                 os.path.isfile("{0}.coverage".format(basename)) or \
-                os.path.isfile("{0}.coverage".format(tbasename))
+                os.path.isfile("{0}.coverage".format(tbasename))) and \
+                self.project.isPy3Project()
         
         # now check the selected item
         itm = self.model().item(self.currentIndex())
@@ -508,8 +509,9 @@
             basename = os.path.splitext(fn)[0]
             prEnable = prEnable or \
                 os.path.isfile("{0}.profile".format(basename))
-            coEnable = coEnable or \
-                os.path.isfile("{0}.coverage".format(basename))
+            coEnable = (coEnable or \
+                os.path.isfile("{0}.coverage".format(basename))) and \
+                itm.isPython3File()
         
         self.profileMenuAction.setEnabled(prEnable)
         self.coverageMenuAction.setEnabled(coEnable)
--- a/PyUnit/UnittestDialog.py	Sat Dec 10 18:01:16 2011 +0100
+++ b/PyUnit/UnittestDialog.py	Sat Dec 17 15:19:45 2011 +0100
@@ -192,7 +192,7 @@
         @param txt name of the test file (string)
         """
         if self.dbs:
-            exts = self.dbs.getExtensions("Python3")
+            exts = self.dbs.getExtensions("Python2")
             if txt.endswith(exts):
                 self.coverageCheckBox.setChecked(False)
                 self.coverageCheckBox.setEnabled(False)
--- a/QScintilla/Editor.py	Sat Dec 10 18:01:16 2011 +0100
+++ b/QScintilla/Editor.py	Sat Dec 17 15:19:45 2011 +0100
@@ -3979,9 +3979,10 @@
                 prEnable = prEnable or \
                     os.path.isfile("{0}.profile".format(basename)) or \
                     os.path.isfile("{0}.profile".format(tbasename))
-                coEnable = coEnable or \
+                coEnable = (coEnable or \
                     os.path.isfile("{0}.coverage".format(basename)) or \
-                    os.path.isfile("{0}.coverage".format(tbasename))
+                    os.path.isfile("{0}.coverage".format(tbasename))) and \
+                    self.project.isPy3Project()
         
         # now check ourself
         fn = self.getFileName()
@@ -3992,9 +3993,10 @@
             prEnable = prEnable or \
                 os.path.isfile("{0}.profile".format(basename)) or \
                 os.path.isfile("{0}.profile".format(tbasename))
-            coEnable = coEnable or \
+            coEnable = (coEnable or \
                 os.path.isfile("{0}.coverage".format(basename)) or \
-                os.path.isfile("{0}.coverage".format(tbasename))
+                os.path.isfile("{0}.coverage".format(tbasename))) and \
+                self.isPy3File()
         
         # now check for syntax errors
         if self.hasSyntaxErrors():

eric ide

mercurial