520 |
520 |
521 # set the autosave flag |
521 # set the autosave flag |
522 self.autosaveEnabled = Preferences.getEditor("AutosaveInterval") > 0 |
522 self.autosaveEnabled = Preferences.getEditor("AutosaveInterval") > 0 |
523 self.autosaveManuallyDisabled = False |
523 self.autosaveManuallyDisabled = False |
524 |
524 |
|
525 # code coverage related attributes |
|
526 self.__coverageFile = "" |
|
527 |
525 self.__initContextMenu() |
528 self.__initContextMenu() |
526 self.__initContextMenuMargins() |
529 self.__initContextMenuMargins() |
527 |
530 |
528 self.__checkEol() |
531 self.__checkEol() |
529 if editor is None: |
532 if editor is None: |
5660 os.path.isfile("{0}.coverage".format(basename)) or |
5663 os.path.isfile("{0}.coverage".format(basename)) or |
5661 os.path.isfile("{0}.coverage".format(tbasename))) and |
5664 os.path.isfile("{0}.coverage".format(tbasename))) and |
5662 self.isPyFile() |
5665 self.isPyFile() |
5663 ) |
5666 ) |
5664 |
5667 |
|
5668 coEnable |= bool(self.__coverageFile) |
|
5669 |
5665 # now check for syntax errors |
5670 # now check for syntax errors |
5666 if self.hasSyntaxErrors(): |
5671 if self.hasSyntaxErrors(): |
5667 coEnable = False |
5672 coEnable = False |
5668 |
5673 |
5669 self.profileMenuAct.setEnabled(prEnable) |
5674 self.profileMenuAct.setEnabled(prEnable) |
6050 |
6055 |
6051 @return file name of the coverage file (string) |
6056 @return file name of the coverage file (string) |
6052 """ |
6057 """ |
6053 files = [] |
6058 files = [] |
6054 |
6059 |
|
6060 if bool(self.__coverageFile): |
|
6061 # return the path of a previously used coverage file |
|
6062 return self.__coverageFile |
|
6063 |
6055 # first check if the file belongs to a project and there is |
6064 # first check if the file belongs to a project and there is |
6056 # a project coverage file |
6065 # a project coverage file |
6057 if ( |
6066 if ( |
6058 self.project.isOpen() and |
6067 self.project.isOpen() and |
6059 self.project.isProjectSource(self.fileName) |
6068 self.project.isProjectSource(self.fileName) |
6105 def __showCodeCoverage(self): |
6114 def __showCodeCoverage(self): |
6106 """ |
6115 """ |
6107 Private method to handle the code coverage context menu action. |
6116 Private method to handle the code coverage context menu action. |
6108 """ |
6117 """ |
6109 fn = self.__getCodeCoverageFile() |
6118 fn = self.__getCodeCoverageFile() |
|
6119 self.__coverageFile = fn |
6110 if fn: |
6120 if fn: |
6111 from DataViews.PyCoverageDialog import PyCoverageDialog |
6121 from DataViews.PyCoverageDialog import PyCoverageDialog |
6112 self.codecoverage = PyCoverageDialog() |
6122 self.codecoverage = PyCoverageDialog() |
6113 self.codecoverage.show() |
6123 self.codecoverage.show() |
6114 self.codecoverage.start(fn, self.fileName) |
6124 self.codecoverage.start(fn, self.fileName) |
6118 Public method to refresh the code coverage annotations. |
6128 Public method to refresh the code coverage annotations. |
6119 """ |
6129 """ |
6120 if self.showingNotcoveredMarkers: |
6130 if self.showingNotcoveredMarkers: |
6121 self.codeCoverageShowAnnotations(silent=True) |
6131 self.codeCoverageShowAnnotations(silent=True) |
6122 |
6132 |
6123 def codeCoverageShowAnnotations(self, silent=False): |
6133 def codeCoverageShowAnnotations(self, silent=False, coverageFile=None): |
6124 """ |
6134 """ |
6125 Public method to handle the show code coverage annotations context |
6135 Public method to handle the show code coverage annotations context |
6126 menu action. |
6136 menu action. |
6127 |
6137 |
6128 @param silent flag indicating to not show any dialog (boolean) |
6138 @param silent flag indicating to not show any dialog (defaults to |
|
6139 False) |
|
6140 @type bool (optional) |
|
6141 @param coverageFile path of the file containing the code coverage data |
|
6142 (defaults to None) |
|
6143 @type str (optional) |
6129 """ |
6144 """ |
6130 self.__codeCoverageHideAnnotations() |
6145 self.__codeCoverageHideAnnotations() |
6131 |
6146 |
6132 fn = self.__getCodeCoverageFile() |
6147 fn = ( |
|
6148 coverageFile |
|
6149 if bool(coverageFile) else |
|
6150 self.__getCodeCoverageFile() |
|
6151 ) |
|
6152 self.__coverageFile = fn |
|
6153 |
6133 if fn: |
6154 if fn: |
6134 from coverage import Coverage |
6155 from coverage import Coverage |
6135 cover = Coverage(data_file=fn) |
6156 cover = Coverage(data_file=fn) |
6136 cover.load() |
6157 cover.load() |
6137 missing = cover.analysis2(self.fileName)[3] |
6158 missing = cover.analysis2(self.fileName)[3] |