PluginProjectPyramid.py

changeset 54
71c83a661c83
parent 48
c313efdb01de
child 57
e654970c913e
diff -r a3ba38d3a25e -r 71c83a661c83 PluginProjectPyramid.py
--- a/PluginProjectPyramid.py	Sat Sep 28 13:34:57 2013 +0200
+++ b/PluginProjectPyramid.py	Fri Oct 25 18:51:52 2013 +0200
@@ -26,11 +26,12 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "1.3.0"
+version = "1.3.1"
 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
@@ -44,6 +45,7 @@
     """
     Module function to create the Pyramid configuration page.
     
+    @param configDlg reference to the configuration dialog
     @return reference to the configuration page
     """
     global pyramidPluginObject
@@ -60,11 +62,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 {}
@@ -74,6 +75,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"]:
@@ -122,7 +124,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():
@@ -159,7 +162,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
         
@@ -187,41 +191,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
     
@@ -231,9 +239,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)
@@ -256,8 +267,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)
@@ -265,8 +276,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):
@@ -277,7 +288,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):
         """
@@ -290,7 +302,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
         """
@@ -312,11 +325,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):
@@ -341,11 +355,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):
         """
@@ -353,9 +366,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()
@@ -376,14 +389,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)

eric ide

mercurial