def __projectBrowserCodeStyleCheck(self): """ Private method to handle the code style check context menu action of the project sources browser. """ browser = e5App().getObject("ProjectBrowser")\ .getProjectBrowser("sources") if browser.getSelectedItemsCount([ProjectBrowserFileItem]) > 1: fn = [] for itm in browser.getSelectedItems([ProjectBrowserFileItem]): fn.append(itm.fileName()) isDir = False else: itm = browser.model().item(browser.currentIndex()) try: fn = itm.fileName() isDir = False except AttributeError: fn = itm.dirName() isDir = True from CheckerPlugins.CodeStyleChecker.CodeStyleCheckerDialog import \ CodeStyleCheckerDialog self.__projectBrowserCodeStyleCheckerDialog = CodeStyleCheckerDialog( self) self.__projectBrowserCodeStyleCheckerDialog.show() if isDir: self.__projectBrowserCodeStyleCheckerDialog.start(fn, save=True) else: self.__projectBrowserCodeStyleCheckerDialog.start(fn, save=True, repeat=True)
def __editorCodeStyleCheck(self): """ Private slot to handle the code style check context menu action of the editors. """ editor = e5App().getObject("ViewManager").activeWindow() if editor is not None: if editor.checkDirty() and editor.getFileName() is not None: from CheckerPlugins.CodeStyleChecker.CodeStyleCheckerDialog \ import CodeStyleCheckerDialog self.__editorCodeStyleCheckerDialog = CodeStyleCheckerDialog( self) self.__editorCodeStyleCheckerDialog.show() self.__editorCodeStyleCheckerDialog.start(editor.getFileName(), save=True, repeat=True)
def __projectCodeStyleCheck(self): """ Private slot used to check the project files for code style. """ project = e5App().getObject("Project") project.saveAllScripts() ppath = project.getProjectPath() files = [ os.path.join(ppath, file) for file in project.pdata["SOURCES"] if file.endswith( tuple(Preferences.getPython("Python3Extensions")) + tuple(Preferences.getPython("PythonExtensions"))) ] from CheckerPlugins.CodeStyleChecker.CodeStyleCheckerDialog import \ CodeStyleCheckerDialog self.__projectCodeStyleCheckerDialog = CodeStyleCheckerDialog(self) self.__projectCodeStyleCheckerDialog.show() self.__projectCodeStyleCheckerDialog.prepare(files, project)