--- a/PluginProjectPyramid.py Sun Oct 27 22:43:17 2013 +0100 +++ b/PluginProjectPyramid.py Tue Oct 29 22:30:48 2013 +0100 @@ -32,7 +32,8 @@ className = "ProjectPyramidPlugin" packageName = "ProjectPyramid" shortDescription = "Project support for Pyramid projects." -longDescription = """This plugin implements project support for Pyramid projects.""" +longDescription = \ + """This plugin implements project support for Pyramid projects.""" needsRestart = False pyqtApi = 2 # End-of-Header @@ -46,6 +47,7 @@ """ Module function to create the Pyramid configuration page. + @param configDlg reference to the configuration dialog @return reference to the configuration page """ global pyramidPluginObject @@ -62,11 +64,10 @@ """ if e5App().getObject("UserInterface").versionIsNewer('5.0.99', '20120101'): return { - "pyramidPage": \ - [QCoreApplication.translate("ProjectPyramidPlugin", "Pyramid"), - os.path.join("ProjectPyramid", "icons", - "pyramid.png"), - createPyramidPage, None, None], + "pyramidPage": [ + QCoreApplication.translate("ProjectPyramidPlugin", "Pyramid"), + os.path.join("ProjectPyramid", "icons", "pyramid.png"), + createPyramidPage, None, None], } else: return {} @@ -76,6 +77,7 @@ """ Module function to return the API files made available by this plugin. + @param language language to get APIs for (string) @return list of API filenames (list of string) """ if language in ["Python3", "Python2"]: @@ -124,7 +126,8 @@ "VirtualEnvironmentPy3": "", "Python2ConsoleType": "python", "Python3ConsoleType": "python", - "PyramidDocUrl": "http://docs.pylonsproject.org/en/latest/docs/pyramid.html", + "PyramidDocUrl": "http://docs.pylonsproject.org/en/latest/" + "docs/pyramid.html", "TranslationsEditor": "", } if isWindowsPlatform(): @@ -161,7 +164,8 @@ if self.__ui.versionIsNewer('5.0.99', '20120101'): error = "" else: - error = self.trUtf8("eric5 version is too old, {0}, {1} or newer needed.")\ + error = self.trUtf8( + "eric5 version is too old, {0}, {1} or newer needed.")\ .format("5.1.0", "20120101") return False @@ -189,41 +193,45 @@ if self.__supportedVariants: try: - self.__e5project.registerProjectType("Pyramid", self.trUtf8("Pyramid"), + self.__e5project.registerProjectType( + "Pyramid", self.trUtf8("Pyramid"), self.fileTypesCallback, lexerAssociationCallback=self.lexerAssociationCallback, binaryTranslationsCallback=self.binaryTranslationsCallback, progLanguages=self.__supportedVariants[:]) except TypeError: # for backward compatibility - self.__e5project.registerProjectType("Pyramid", self.trUtf8("Pyramid"), + self.__e5project.registerProjectType( + "Pyramid", self.trUtf8("Pyramid"), self.fileTypesCallback, lexerAssociationCallback=self.lexerAssociationCallback, binaryTranslationsCallback=self.binaryTranslationsCallback) - from Project.ProjectBrowser import SourcesBrowserFlag, FormsBrowserFlag, \ - TranslationsBrowserFlag, OthersBrowserFlag - Preferences.setProjectBrowserFlagsDefault("Pyramid", - SourcesBrowserFlag | \ - FormsBrowserFlag | \ - TranslationsBrowserFlag | \ - OthersBrowserFlag, + from Project.ProjectBrowser import SourcesBrowserFlag, \ + FormsBrowserFlag, TranslationsBrowserFlag, OthersBrowserFlag + Preferences.setProjectBrowserFlagsDefault( + "Pyramid", + SourcesBrowserFlag | FormsBrowserFlag | + TranslationsBrowserFlag | OthersBrowserFlag, ) if self.__e5project.isOpen(): self.__projectOpened() self.__object.projectOpenedHooks() - e5App().getObject("Project").projectOpened.connect(self.__projectOpened) - e5App().getObject("Project").projectClosed.connect(self.__projectClosed) - e5App().getObject("Project").newProject.connect(self.__projectOpened) + e5App().getObject("Project").projectOpened.connect( + self.__projectOpened) + e5App().getObject("Project").projectClosed.connect( + self.__projectClosed) + e5App().getObject("Project").newProject.connect( + self.__projectOpened) e5App().getObject("Project").projectOpenedHooks.connect( self.__object.projectOpenedHooks) e5App().getObject("Project").projectClosedHooks.connect( - self.__object.projectClosedHooks) + self.__object.projectClosedHooks) e5App().getObject("Project").newProjectHooks.connect( - self.__object.projectOpenedHooks) + self.__object.projectOpenedHooks) return None, True @@ -233,9 +241,12 @@ """ e5App().unregisterPluginObject("ProjectPyramid") - e5App().getObject("Project").projectOpened.disconnect(self.__projectOpened) - e5App().getObject("Project").projectClosed.disconnect(self.__projectClosed) - e5App().getObject("Project").newProject.disconnect(self.__projectOpened) + e5App().getObject("Project").projectOpened.disconnect( + self.__projectOpened) + e5App().getObject("Project").projectClosed.disconnect( + self.__projectClosed) + e5App().getObject("Project").newProject.disconnect( + self.__projectOpened) e5App().getObject("Project").projectOpenedHooks.disconnect( self.__object.projectOpenedHooks) @@ -258,8 +269,8 @@ if self.__ui is not None: loc = self.__ui.getLocale() if loc and loc != "C": - locale_dir = \ - os.path.join(os.path.dirname(__file__), "ProjectPyramid", "i18n") + locale_dir = os.path.join( + os.path.dirname(__file__), "ProjectPyramid", "i18n") translation = "pyramid_%s" % loc translator = QTranslator(None) loaded = translator.load(translation, locale_dir) @@ -267,8 +278,8 @@ self.__translator = translator e5App().installTranslator(self.__translator) else: - print("Warning: translation file '{0}' could not be loaded.".format( - translation)) + print("Warning: translation file '{0}' could not be" + " loaded.".format(translation)) print("Using default.") def __projectOpened(self): @@ -279,7 +290,8 @@ projectAct = self.__ui.getMenuBarAction("project") actions = self.__ui.menuBar().actions() insertAct = actions[actions.index(projectAct) + 1] - self.__mainAct = self.__ui.menuBar().insertMenu(insertAct, self.__mainMenu) + self.__mainAct = self.__ui.menuBar().insertMenu( + insertAct, self.__mainMenu) def __projectClosed(self): """ @@ -292,7 +304,8 @@ def fileTypesCallback(self): """ - Public method get the filetype associations of the Pyramid project type. + Public method get the filetype associations of the Pyramid project + type. @return dictionary with file type associations """ @@ -314,11 +327,12 @@ def lexerAssociationCallback(self, filename): """ - Public method to get the lexer association of the Pyramid project type for - a file. + Public method to get the lexer association of the Pyramid project type + for a file. @param filename name of the file (string) - @return name of the lexer (string) (Pygments lexers are prefixed with 'Pygments|') + @return name of the lexer (string) (Pygments lexers are prefixed with + 'Pygments|') """ for pattern, language in self.lexerAssociations.items(): if fnmatch.fnmatch(filename, pattern): @@ -343,11 +357,10 @@ Public method to retrieve the various settings. @param key the key of the value to get - @param prefClass preferences class used as the storage area @return the requested setting """ - return Preferences.Prefs.settings.value(self.PreferencesKey + "/" + key, - self.__defaults[key]) + return Preferences.Prefs.settings.value( + self.PreferencesKey + "/" + key, self.__defaults[key]) def setPreferences(self, key, value): """ @@ -355,9 +368,9 @@ @param key the key of the setting to be set (string) @param value the value to be set - @param prefClass preferences class used as the storage area """ - Preferences.Prefs.settings.setValue(self.PreferencesKey + "/" + key, value) + Preferences.Prefs.settings.setValue( + self.PreferencesKey + "/" + key, value) if key in ["VirtualEnvironmentPy2", "VirtualEnvironmentPy3"]: self.__reregisterProjectType() @@ -378,14 +391,18 @@ self.__supportedVariants = supportedVariants if self.__supportedVariants: try: - self.__e5project.registerProjectType("Pyramid", + self.__e5project.registerProjectType( + "Pyramid", self.trUtf8("Pyramid"), self.fileTypesCallback, lexerAssociationCallback=self.lexerAssociationCallback, - binaryTranslationsCallback=self.binaryTranslationsCallback, + binaryTranslationsCallback= + self.binaryTranslationsCallback, progLanguages=self.__supportedVariants[:]) except TypeError: # for backward compatibility - self.__e5project.registerProjectType("Pyramid", + self.__e5project.registerProjectType( + "Pyramid", self.trUtf8("Pyramid"), self.fileTypesCallback, lexerAssociationCallback=self.lexerAssociationCallback, - binaryTranslationsCallback=self.binaryTranslationsCallback) + binaryTranslationsCallback= + self.binaryTranslationsCallback)