78 self.__projectAct = E5Action( |
78 self.__projectAct = E5Action( |
79 self.trUtf8('Check Code Style'), |
79 self.trUtf8('Check Code Style'), |
80 self.trUtf8('&Code Style...'), 0, 0, |
80 self.trUtf8('&Code Style...'), 0, 0, |
81 self, 'project_check_pep8') |
81 self, 'project_check_pep8') |
82 self.__projectAct.setStatusTip( |
82 self.__projectAct.setStatusTip( |
83 self.trUtf8('Check PEP 8 compliance.')) |
83 self.trUtf8('Check code style.')) |
84 self.__projectAct.setWhatsThis(self.trUtf8( |
84 self.__projectAct.setWhatsThis(self.trUtf8( |
85 """<b>Check Code Style...</b>""" |
85 """<b>Check Code Style...</b>""" |
86 """<p>This checks Python files for compliance to the""" |
86 """<p>This checks Python files for compliance to the""" |
87 """ code style conventions given in various PEPs.</p>""" |
87 """ code style conventions given in various PEPs.</p>""" |
88 )) |
88 )) |
184 if not self.__projectBrowserAct in menu.actions(): |
184 if not self.__projectBrowserAct in menu.actions(): |
185 menu.addAction(self.__projectBrowserAct) |
185 menu.addAction(self.__projectBrowserAct) |
186 |
186 |
187 def __projectPep8Check(self): |
187 def __projectPep8Check(self): |
188 """ |
188 """ |
189 Public slot used to check the project files for PEP 8 compliance. |
189 Public slot used to check the project files for code style. |
190 """ |
190 """ |
191 project = e5App().getObject("Project") |
191 project = e5App().getObject("Project") |
192 project.saveAllScripts() |
192 project.saveAllScripts() |
193 ppath = project.getProjectPath() |
193 ppath = project.getProjectPath() |
194 files = [os.path.join(ppath, file) |
194 files = [os.path.join(ppath, file) |
203 self.__projectPep8CheckerDialog.show() |
203 self.__projectPep8CheckerDialog.show() |
204 self.__projectPep8CheckerDialog.prepare(files, project) |
204 self.__projectPep8CheckerDialog.prepare(files, project) |
205 |
205 |
206 def __projectBrowserPep8Check(self): |
206 def __projectBrowserPep8Check(self): |
207 """ |
207 """ |
208 Private method to handle the PEP 8 check context menu action of |
208 Private method to handle the code style check context menu action of |
209 the project sources browser. |
209 the project sources browser. |
210 """ |
210 """ |
211 browser = e5App().getObject("ProjectBrowser")\ |
211 browser = e5App().getObject("ProjectBrowser")\ |
212 .getProjectBrowser("sources") |
212 .getProjectBrowser("sources") |
213 itm = browser.model().item(browser.currentIndex()) |
213 itm = browser.model().item(browser.currentIndex()) |
267 self.__editorAct.setEnabled( |
267 self.__editorAct.setEnabled( |
268 editor.isPy3File() or editor.isPy2File()) |
268 editor.isPy3File() or editor.isPy2File()) |
269 |
269 |
270 def __editorPep8Check(self): |
270 def __editorPep8Check(self): |
271 """ |
271 """ |
272 Private slot to handle the PEP 8 check context menu action |
272 Private slot to handle the code style check context menu action |
273 of the editors. |
273 of the editors. |
274 """ |
274 """ |
275 editor = e5App().getObject("ViewManager").activeWindow() |
275 editor = e5App().getObject("ViewManager").activeWindow() |
276 if editor is not None: |
276 if editor is not None: |
277 if editor.checkDirty() and editor.getFileName() is not None: |
277 if editor.checkDirty() and editor.getFileName() is not None: |