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

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

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 17 Dec 2011 15:19:45 +0100
changeset 1491
985c5abc8226
parent 1490
ed6f2208297d
child 1492
efbc0a2528a1

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

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	Wed Dec 14 19:57:54 2011 +0100
+++ b/Project/Project.py	Sat Dec 17 15:19:45 2011 +0100
@@ -2647,6 +2647,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.
@@ -3871,7 +3895,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	Wed Dec 14 19:57:54 2011 +0100
+++ b/Project/ProjectSourcesBrowser.py	Sat Dec 17 15:19:45 2011 +0100
@@ -547,9 +547,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())
@@ -558,8 +559,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	Wed Dec 14 19:57:54 2011 +0100
+++ b/PyUnit/UnittestDialog.py	Sat Dec 17 15:19:45 2011 +0100
@@ -199,7 +199,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	Wed Dec 14 19:57:54 2011 +0100
+++ b/QScintilla/Editor.py	Sat Dec 17 15:19:45 2011 +0100
@@ -4166,9 +4166,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()
@@ -4179,9 +4180,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