ProjectPyramid/Project.py

changeset 57
e654970c913e
parent 56
c7adc68350dd
parent 54
71c83a661c83
child 58
6acbfbba1e9d
--- a/ProjectPyramid/Project.py	Sun Oct 27 22:43:17 2013 +0100
+++ b/ProjectPyramid/Project.py	Tue Oct 29 22:30:48 2013 +0100
@@ -20,7 +20,8 @@
 import sys
 
 from PyQt4.QtCore import QObject, QFileInfo, QTimer, QUrl
-from PyQt4.QtGui import QMenu, QDialog, QInputDialog, QDesktopServices, QLineEdit
+from PyQt4.QtGui import QMenu, QDialog, QInputDialog, QDesktopServices, \
+    QLineEdit
 from PyQt4.QtCore import QProcess as QProcessPyQt
 
 from E5Gui.E5Application import e5App
@@ -107,10 +108,11 @@
         """
         self.actions = []
     
-        self.selectProjectAct = E5Action(self.trUtf8('Current Pyramid Project'),
-                "",
-                0, 0,
-                self, 'pyramid_current_project')
+        self.selectProjectAct = E5Action(
+            self.trUtf8('Current Pyramid Project'),
+            "",
+            0, 0,
+            self, 'pyramid_current_project')
         self.selectProjectAct.setStatusTip(self.trUtf8(
             'Selects the current Pyramid project'))
         self.selectProjectAct.setWhatsThis(self.trUtf8(
@@ -125,10 +127,11 @@
         ## create actions below      ##
         ###############################
         
-        self.createProjectAct = E5Action(self.trUtf8('Create Pyramid Project'),
-                self.trUtf8('Create Pyramid &Project'),
-                0, 0,
-                self, 'pyramid_create_project')
+        self.createProjectAct = E5Action(
+            self.trUtf8('Create Pyramid Project'),
+            self.trUtf8('Create Pyramid &Project'),
+            0, 0,
+            self, 'pyramid_create_project')
         self.createProjectAct.setStatusTip(self.trUtf8(
             'Creates a new Pyramid project'))
         self.createProjectAct.setWhatsThis(self.trUtf8(
@@ -142,10 +145,11 @@
         ## run actions below        ##
         ##############################
         
-        self.runServerAct = E5Action(self.trUtf8('Run Server'),
-                self.trUtf8('Run &Server'),
-                0, 0,
-                self, 'pyramid_run_server')
+        self.runServerAct = E5Action(
+            self.trUtf8('Run Server'),
+            self.trUtf8('Run &Server'),
+            0, 0,
+            self, 'pyramid_run_server')
         self.runServerAct.setStatusTip(self.trUtf8(
             'Starts the Pyramid Web server'))
         self.runServerAct.setWhatsThis(self.trUtf8(
@@ -156,10 +160,11 @@
         self.runServerAct.triggered[()].connect(self.__runServer)
         self.actions.append(self.runServerAct)
         
-        self.runLoggingServerAct = E5Action(self.trUtf8('Run Server with Logging'),
-                self.trUtf8('Run Server with &Logging'),
-                0, 0,
-                self, 'pyramid_run_logging_server')
+        self.runLoggingServerAct = E5Action(
+            self.trUtf8('Run Server with Logging'),
+            self.trUtf8('Run Server with &Logging'),
+            0, 0,
+            self, 'pyramid_run_logging_server')
         self.runLoggingServerAct.setStatusTip(self.trUtf8(
             'Starts the Pyramid Web server with logging'))
         self.runLoggingServerAct.setWhatsThis(self.trUtf8(
@@ -170,12 +175,14 @@
         self.runLoggingServerAct.triggered[()].connect(self.__runLoggingServer)
         self.actions.append(self.runLoggingServerAct)
         
-        self.runBrowserAct = E5Action(self.trUtf8('Run Web-Browser'),
-                self.trUtf8('Run &Web-Browser'),
-                0, 0,
-                self, 'pyramid_run_browser')
+        self.runBrowserAct = E5Action(
+            self.trUtf8('Run Web-Browser'),
+            self.trUtf8('Run &Web-Browser'),
+            0, 0,
+            self, 'pyramid_run_browser')
         self.runBrowserAct.setStatusTip(self.trUtf8(
-            'Starts the default Web-Browser with the URL of the Pyramid Web server'))
+            'Starts the default Web-Browser with the URL of the Pyramid Web'
+            ' server'))
         self.runBrowserAct.setWhatsThis(self.trUtf8(
             """<b>Run Web-Browser</b>"""
             """<p>Starts the default Web-Browser with the URL of the """
@@ -184,10 +191,11 @@
         self.runBrowserAct.triggered[()].connect(self.__runBrowser)
         self.actions.append(self.runBrowserAct)
     
-        self.runPythonShellAct = E5Action(self.trUtf8('Start Pyramid Python Console'),
-                self.trUtf8('Start Pyramid &Python Console'),
-                0, 0,
-                self, 'pyramid_python_console')
+        self.runPythonShellAct = E5Action(
+            self.trUtf8('Start Pyramid Python Console'),
+            self.trUtf8('Start Pyramid &Python Console'),
+            0, 0,
+            self, 'pyramid_python_console')
         self.runPythonShellAct.setStatusTip(self.trUtf8(
             'Starts an interactive Python interpreter'))
         self.runPythonShellAct.setWhatsThis(self.trUtf8(
@@ -201,10 +209,11 @@
         ## setup actions below      ##
         ##############################
         
-        self.setupDevelopAct = E5Action(self.trUtf8('Setup Development Environment'),
-                self.trUtf8('Setup &Development Environment'),
-                0, 0,
-                self, 'pyramid_setup_development')
+        self.setupDevelopAct = E5Action(
+            self.trUtf8('Setup Development Environment'),
+            self.trUtf8('Setup &Development Environment'),
+            0, 0,
+            self, 'pyramid_setup_development')
         self.setupDevelopAct.setStatusTip(self.trUtf8(
             'Setup the Pyramid project in development mode'))
         self.setupDevelopAct.setWhatsThis(self.trUtf8(
@@ -219,17 +228,18 @@
         ## database actions below    ##
         ###############################
         
-        self.initializeDbAct = E5Action(self.trUtf8('Initialize Database'),
-                self.trUtf8('Initialize &Database'),
-                0, 0,
-                self, 'pyramid_initialize_database')
+        self.initializeDbAct = E5Action(
+            self.trUtf8('Initialize Database'),
+            self.trUtf8('Initialize &Database'),
+            0, 0,
+            self, 'pyramid_initialize_database')
         self.initializeDbAct.setStatusTip(self.trUtf8(
             'Initializes (or re-initializes) the database of the current'
             ' Pyramid project'))
         self.initializeDbAct.setWhatsThis(self.trUtf8(
             """<b>Initialize Database</b>"""
-            """<p>Initializes (or re-initializes) the database of the current"""
-            """ Pyramid project.</p>"""
+            """<p>Initializes (or re-initializes) the database of the"""
+            """ current Pyramid project.</p>"""
         ))
         self.initializeDbAct.triggered[()].connect(self.__initializeDatabase)
         self.actions.append(self.initializeDbAct)
@@ -238,10 +248,11 @@
         ## show actions below        ##
         ###############################
         
-        self.showViewsAct = E5Action(self.trUtf8('Show Matching Views'),
-                self.trUtf8('Show Matching &Views'),
-                0, 0,
-                self, 'pyramid_show_views')
+        self.showViewsAct = E5Action(
+            self.trUtf8('Show Matching Views'),
+            self.trUtf8('Show Matching &Views'),
+            0, 0,
+            self, 'pyramid_show_views')
         self.showViewsAct.setStatusTip(self.trUtf8(
             'Show views matching a given URL'))
         self.showViewsAct.setWhatsThis(self.trUtf8(
@@ -251,10 +262,11 @@
         self.showViewsAct.triggered[()].connect(self.__showMatchingViews)
         self.actions.append(self.showViewsAct)
         
-        self.showRoutesAct = E5Action(self.trUtf8('Show Routes'),
-                self.trUtf8('Show &Routes'),
-                0, 0,
-                self, 'pyramid_show_routes')
+        self.showRoutesAct = E5Action(
+            self.trUtf8('Show Routes'),
+            self.trUtf8('Show &Routes'),
+            0, 0,
+            self, 'pyramid_show_routes')
         self.showRoutesAct.setStatusTip(self.trUtf8(
             'Show all URL dispatch routes used by a Pyramid application'))
         self.showRoutesAct.setWhatsThis(self.trUtf8(
@@ -265,12 +277,14 @@
         self.showRoutesAct.triggered[()].connect(self.__showRoutes)
         self.actions.append(self.showRoutesAct)
         
-        self.showTweensAct = E5Action(self.trUtf8('Show Tween Objects'),
-                self.trUtf8('Show &Tween Objects'),
-                0, 0,
-                self, 'pyramid_show_routes')
+        self.showTweensAct = E5Action(
+            self.trUtf8('Show Tween Objects'),
+            self.trUtf8('Show &Tween Objects'),
+            0, 0,
+            self, 'pyramid_show_routes')
         self.showTweensAct.setStatusTip(self.trUtf8(
-            'Show all implicit and explicit tween objects used by a Pyramid application'))
+            'Show all implicit and explicit tween objects used by a Pyramid'
+            ' application'))
         self.showTweensAct.setWhatsThis(self.trUtf8(
             """<b>Show Tween Objects</b>"""
             """<p>Show all implicit and explicit tween objects used by a"""
@@ -283,10 +297,11 @@
         ## distribution actions below   ##
         ##################################
         
-        self.buildDistroAct = E5Action(self.trUtf8('Build Distribution'),
-                self.trUtf8('Build &Distribution'),
-                0, 0,
-                self, 'pyramid_build_distribution')
+        self.buildDistroAct = E5Action(
+            self.trUtf8('Build Distribution'),
+            self.trUtf8('Build &Distribution'),
+            0, 0,
+            self, 'pyramid_build_distribution')
         self.buildDistroAct.setStatusTip(self.trUtf8(
             'Builds a distribution file for the Pyramid project'))
         self.buildDistroAct.setWhatsThis(self.trUtf8(
@@ -301,10 +316,11 @@
         ## documentation action below   ##
         ##################################
         
-        self.documentationAct = E5Action(self.trUtf8('Documentation'),
-                self.trUtf8('D&ocumentation'),
-                0, 0,
-                self, 'pyramid_documentation')
+        self.documentationAct = E5Action(
+            self.trUtf8('Documentation'),
+            self.trUtf8('D&ocumentation'),
+            0, 0,
+            self, 'pyramid_documentation')
         self.documentationAct.setStatusTip(self.trUtf8(
             'Shows the help viewer with the Pyramid documentation'))
         self.documentationAct.setWhatsThis(self.trUtf8(
@@ -318,10 +334,11 @@
         ## about action below       ##
         ##############################
         
-        self.aboutPyramidAct = E5Action(self.trUtf8('About Pyramid'),
-                self.trUtf8('About P&yramid'),
-                0, 0,
-                self, 'pyramid_about')
+        self.aboutPyramidAct = E5Action(
+            self.trUtf8('About Pyramid'),
+            self.trUtf8('About P&yramid'),
+            0, 0,
+            self, 'pyramid_about')
         self.aboutPyramidAct.setStatusTip(self.trUtf8(
             'Shows some information about Pyramid'))
         self.aboutPyramidAct.setWhatsThis(self.trUtf8(
@@ -378,9 +395,10 @@
             editor = self.__plugin.getPreferences("TranslationsEditor")
             try:
                 if editor:
-                    self.__translationsBrowser.addHookMethodAndMenuEntry("open",
-                        self.openPOEditor,
-                        self.trUtf8("Open with {0}").format(os.path.basename(editor)))
+                    self.__translationsBrowser.addHookMethodAndMenuEntry(
+                        "open", self.openPOEditor,
+                        self.trUtf8("Open with {0}").format(
+                            os.path.basename(editor)))
                 else:
                     self.__translationsBrowser.removeHookMethod("open")
             except KeyError:
@@ -394,26 +412,31 @@
         if self.__e5project.getProjectType() == "Pyramid":
             self.__formsBrowser = \
                 e5App().getObject("ProjectBrowser").getProjectBrowser("forms")
-            self.__formsBrowser.addHookMethodAndMenuEntry("newForm",
-                self.newForm, self.trUtf8("New template..."))
+            self.__formsBrowser.addHookMethodAndMenuEntry(
+                "newForm", self.newForm, self.trUtf8("New template..."))
             
             if self.__e5project.getProjectLanguage() == "Python2":
                 # Babel and lingua are not yet available for Python 3
                 self.__e5project.projectLanguageAddedByCode.connect(
                     self.__projectLanguageAdded)
                 self.__translationsBrowser = \
-                    e5App().getObject("ProjectBrowser").getProjectBrowser("translations")
-                self.__translationsBrowser.addHookMethodAndMenuEntry("extractMessages",
-                    self.extractMessages, self.trUtf8("Extract Messages"))
-                self.__translationsBrowser.addHookMethodAndMenuEntry("releaseAll",
-                    self.compileCatalogs, self.trUtf8("Compile All Catalogs"))
-                self.__translationsBrowser.addHookMethodAndMenuEntry("releaseSelected",
-                    self.compileSelectedCatalogs,
+                    e5App().getObject("ProjectBrowser")\
+                    .getProjectBrowser("translations")
+                self.__translationsBrowser.addHookMethodAndMenuEntry(
+                    "extractMessages", self.extractMessages,
+                    self.trUtf8("Extract Messages"))
+                self.__translationsBrowser.addHookMethodAndMenuEntry(
+                    "releaseAll", self.compileCatalogs,
+                    self.trUtf8("Compile All Catalogs"))
+                self.__translationsBrowser.addHookMethodAndMenuEntry(
+                    "releaseSelected", self.compileSelectedCatalogs,
                     self.trUtf8("Compile Selected Catalogs"))
-                self.__translationsBrowser.addHookMethodAndMenuEntry("generateAll",
-                    self.updateCatalogs, self.trUtf8("Update All Catalogs"))
-                self.__translationsBrowser.addHookMethodAndMenuEntry("generateSelected",
-                    self.updateSelectedCatalogs, self.trUtf8("Update Selected Catalogs"))
+                self.__translationsBrowser.addHookMethodAndMenuEntry(
+                    "generateAll", self.updateCatalogs,
+                    self.trUtf8("Update All Catalogs"))
+                self.__translationsBrowser.addHookMethodAndMenuEntry(
+                    "generateSelected", self.updateSelectedCatalogs,
+                    self.trUtf8("Update Selected Catalogs"))
                 
                 self.__hooksInstalled = True
             
@@ -478,9 +501,11 @@
                         fname += ex
             
                 if os.path.exists(fname):
-                    res = E5MessageBox.yesNo(self.__ui,
+                    res = E5MessageBox.yesNo(
+                        self.__ui,
                         self.trUtf8("New Form"),
-                        self.trUtf8("""The file already exists! Overwrite it?"""),
+                        self.trUtf8("""The file already exists! Overwrite"""
+                                    """ it?"""),
                         icon=E5MessageBox.Warning)
                     if not res:
                         # user selected to not overwrite
@@ -491,11 +516,12 @@
                     f.write(template)
                     f.close()
                 except IOError as e:
-                    E5MessageBox.critical(self,
+                    E5MessageBox.critical(
+                        self.__ui,
                         self.trUtf8("New Form"),
-                        self.trUtf8("<p>The new form file <b>{0}</b> could not be"
-                            " created.<br/>"
-                            "Problem: {1}</p>").format(fname, e))
+                        self.trUtf8("<p>The new form file <b>{0}</b> could"
+                                    " not be created.<br/> Problem: {1}</p>")
+                                    .format(fname, e))
                     return
                 
                 self.__e5project.appendFile(fname)
@@ -519,9 +545,9 @@
         the environment.
         
         @param file filename of the executable (string)
-        @return list of full executable names, if the executable file is accessible
-            via the searchpath defined by the PATH environment variable, or an
-            empty list otherwise.
+        @return list of full executable names, if the executable file is
+            accessible via the searchpath defined by the PATH environment
+            variable, or an empty list otherwise.
         """
         paths = []
         
@@ -583,8 +609,8 @@
                             l0 = ""
                         if variant.lower() in l0.lower() or \
                             "{0}.".format(variant[-1]) in l0 or \
-                            (variant == "Python2" and \
-                            "python3" not in l0.lower() and \
+                            (variant == "Python2" and
+                            "python3" not in l0.lower() and
                             "python" in l0.lower()):
                                 variants.append(variant)
                                 break
@@ -697,11 +723,13 @@
         version = self.getPyramidVersion()
         url = "http://www.pylonsproject.org/projects/pyramid/about"
         
-        msgBox = E5MessageBox.E5MessageBox(E5MessageBox.Question,
+        msgBox = E5MessageBox.E5MessageBox(
+            E5MessageBox.Question,
             self.trUtf8("About Pyramid"),
             self.trUtf8(
-                "<p>Pyramid is a high-level Python Web framework that encourages rapid "
-                "development and clean, pragmatic design.</p>"
+                "<p>Pyramid is a high-level Python Web framework that"
+                " encourages rapid development and clean, pragmatic"
+                " design.</p>"
                 "<p><table>"
                 "<tr><td>Version:</td><td>{0}</td></tr>"
                 "<tr><td>URL:</td><td><a href=\"{1}\">"
@@ -777,19 +805,22 @@
             args.append("--scaffold={0}".format(scaffold))
             args.append(project)
             dlg = PyramidDialog(self.trUtf8("Create Pyramid Project"),
-                linewrap=False, parent=self.__ui)
+                                linewrap=False, parent=self.__ui)
             if dlg.startProcess(cmd, args, self.__e5project.getProjectPath()):
                 dlg.exec_()
                 if dlg.normalExit() and not simulate:
-                    # search for files created by pcreate and add them to the project
-                    projectPath = os.path.join(self.__e5project.getProjectPath(), project)
+                    # search for files created by pcreate and add them to the
+                    # project
+                    projectPath = os.path.join(
+                        self.__e5project.getProjectPath(), project)
                     for entry in os.walk(projectPath):
                         for fileName in entry[2]:
                             fullName = os.path.join(entry[0], fileName)
                             self.__e5project.appendFile(fullName)
                     
                     # create the base directory for translations
-                    i18nPath = os.path.join(projectPath, project.lower(), "i18n")
+                    i18nPath = os.path.join(
+                        projectPath, project.lower(), "i18n")
                     if not os.path.exists(i18nPath):
                         os.makedirs(i18nPath)
                     self.__e5project.setDirty(True)
@@ -818,8 +849,6 @@
     def __selectProject(self):
         """
         Private method to select a Pyramid project to work with.
-        
-        @return selected project (string)
         """
         projects = self.__findProjects()
         if len(projects) == 0:
@@ -848,7 +877,8 @@
         """
         Private method to calculate the full path of the Pyramid project.
         
-        @exception PyramidNoProjectSelectedException raised, if no project is selected
+        @exception PyramidNoProjectSelectedException raised, if no project is
+            selected
         @return path of the project (string)
         """
         if self.__currentProject is None:
@@ -894,7 +924,7 @@
                 domain = lowerProject
             self.__e5project.pdata["TRANSLATIONPATTERN"] = [
                 os.path.join(project, outputDir, "%language%",
-                    "LC_MESSAGES", "{0}.po".format(domain))
+                             "LC_MESSAGES", "{0}.po".format(domain))
             ]
         
         if self.__currentProject is None:
@@ -907,7 +937,8 @@
         """
         Private method to get the name of the current Pyramid project.
         
-        @exception PyramidNoProjectSelectedException raised, if no project is selected
+        @exception PyramidNoProjectSelectedException raised, if no project is
+            selected
         @return name of the project (string)
         """
         if self.__currentProject is None:
@@ -934,10 +965,11 @@
             try:
                 projectPath = self.__projectPath()
             except PyramidNoProjectSelectedException:
-                E5MessageBox.warning(self.__ui,
+                E5MessageBox.warning(
+                    self.__ui,
                     self.trUtf8('Run Server'),
-                    self.trUtf8('No current Pyramid project selected or no Pyramid '
-                                'project created yet. Aborting...'))
+                    self.trUtf8('No current Pyramid project selected or no'
+                                ' Pyramid project created yet. Aborting...'))
                 return
             
             args = Utilities.parseOptionString(consoleCmd)
@@ -961,7 +993,8 @@
                 self.__serverProc.start(args[0], args[1:])
                 serverProcStarted = self.__serverProc.waitForStarted()
             if not serverProcStarted:
-                E5MessageBox.critical(self.__ui,
+                E5MessageBox.critical(
+                    self.__ui,
                     self.trUtf8('Process Generation Error'),
                     self.trUtf8('The Pyramid server could not be started.'))
     
@@ -989,10 +1022,11 @@
         try:
             projectPath = self.__projectPath()
         except PyramidNoProjectSelectedException:
-            E5MessageBox.warning(self.__ui,
+            E5MessageBox.warning(
+                self.__ui,
                 self.trUtf8('Run Web-Browser'),
-                self.trUtf8('No current Pyramid project selected or no Pyramid project'
-                            ' created yet. Aborting...'))
+                self.trUtf8('No current Pyramid project selected or no Pyramid'
+                            ' project created yet. Aborting...'))
             return
         
         config = configparser.ConfigParser()
@@ -1004,10 +1038,11 @@
         url = QUrl("http://localhost:{0}".format(port))
         res = QDesktopServices.openUrl(url)
         if not res:
-            E5MessageBox.critical(self.__ui,
+            E5MessageBox.critical(
+                self.__ui,
                 self.trUtf8('Run Web-Browser'),
-                self.trUtf8('Could not start the web-browser for the URL "{0}".')\
-                    .format(url.toString()))
+                self.trUtf8('Could not start the web-browser for the URL'
+                            ' "{0}".').format(url.toString()))
     
     def __runPythonShell(self):
         """
@@ -1019,10 +1054,11 @@
             try:
                 projectPath = self.__projectPath()
             except PyramidNoProjectSelectedException:
-                E5MessageBox.warning(self.__ui,
+                E5MessageBox.warning(
+                    self.__ui,
                     self.trUtf8('Start Pyramid Python Console'),
-                    self.trUtf8('No current Pyramid project selected or no Pyramid '
-                                'project created yet. Aborting...'))
+                    self.trUtf8('No current Pyramid project selected or no'
+                                ' Pyramid project created yet. Aborting...'))
                 return
             
             args = Utilities.parseOptionString(consoleCmd)
@@ -1030,17 +1066,22 @@
             args.append(self.getPyramidCommand("pshell"))
             language = self.__e5project.getProjectLanguage()
             if language == "Python2":
-                consoleType = self.__plugin.getPreferences("Python2ConsoleType")
+                consoleType = self.__plugin.getPreferences(
+                    "Python2ConsoleType")
             else:
-                consoleType = self.__plugin.getPreferences("Python3ConsoleType")
+                consoleType = self.__plugin.getPreferences(
+                    "Python3ConsoleType")
             args.append("--python-shell={0}".format(consoleType))
             args.append(os.path.join(projectPath, "development.ini"))
             
-            started, pid = QProcess.startDetached(args[0], args[1:], projectPath)
+            started, pid = QProcess.startDetached(
+                args[0], args[1:], projectPath)
             if not started:
-                E5MessageBox.critical(self.__ui,
+                E5MessageBox.critical(
+                    self.__ui,
                     self.trUtf8('Process Generation Error'),
-                    self.trUtf8('The Pyramid Shell process could not be started.'))
+                    self.trUtf8('The Pyramid Shell process could not be'
+                                ' started.'))
 
     ##################################################################
     ## slots below implement setup functions
@@ -1048,16 +1089,18 @@
     
     def __setupDevelop(self):
         """
-        Private slot to set up the development environment for the current project.
+        Private slot to set up the development environment for the current
+        project.
         """
         title = self.trUtf8("Setup Development Environment")
         try:
             wd = self.__projectPath()
         except PyramidNoProjectSelectedException:
-            E5MessageBox.warning(self.__ui,
+            E5MessageBox.warning(
+                self.__ui,
                 title,
-                self.trUtf8('No current Pyramid project selected or no Pyramid project'
-                            ' created yet. Aborting...'))
+                self.trUtf8('No current Pyramid project selected or no Pyramid'
+                            ' project created yet. Aborting...'))
             return
         
         cmd = self.getPythonCommand()
@@ -1065,8 +1108,10 @@
         args.append("setup.py")
         args.append("develop")
         
-        dia = PyramidDialog(title,
-            msgSuccess=self.trUtf8("Pyramid development environment setup successfully."))
+        dia = PyramidDialog(
+            title,
+            msgSuccess=self.trUtf8("Pyramid development environment setup"
+                                   " successfully."))
         res = dia.startProcess(cmd, args, wd)
         if res:
             dia.exec_()
@@ -1079,19 +1124,22 @@
     
     def __buildDistribution(self):
         """
-        Private slot to build a distribution file for the current Pyramid project.
+        Private slot to build a distribution file for the current Pyramid
+        project.
         """
         title = self.trUtf8("Build Distribution File")
         try:
             projectPath = self.__projectPath()
         except PyramidNoProjectSelectedException:
-            E5MessageBox.warning(self.__ui,
+            E5MessageBox.warning(
+                self.__ui,
                 title,
-                self.trUtf8('No current Pyramid project selected or no Pyramid project'
-                            ' created yet. Aborting...'))
+                self.trUtf8('No current Pyramid project selected or no Pyramid'
+                            ' project created yet. Aborting...'))
             return
         
-        from .DistributionTypeSelectionDialog import DistributionTypeSelectionDialog
+        from .DistributionTypeSelectionDialog import \
+            DistributionTypeSelectionDialog
         
         dlg = DistributionTypeSelectionDialog(self, projectPath, self.__ui)
         if dlg.exec_() == QDialog.Accepted:
@@ -1103,8 +1151,10 @@
             if formats:
                 args.append("--formats={0}".format(','.join(formats)))
             
-            dia = PyramidDialog(title,
-                msgSuccess=self.trUtf8("Python distribution file built successfully."))
+            dia = PyramidDialog(
+                title,
+                msgSuccess=self.trUtf8("Python distribution file built"
+                                       " successfully."))
             res = dia.startProcess(cmd, args, projectPath)
             if res:
                 dia.exec_()
@@ -1123,10 +1173,11 @@
             cmd = "initialize_{0}_db".format(self.__project())
             return self.getPyramidCommand(cmd)
         except PyramidNoProjectSelectedException:
-            E5MessageBox.warning(self.__ui,
+            E5MessageBox.warning(
+                self.__ui,
                 self.trUtf8("Initialize Database"),
-                self.trUtf8('No current Pyramid project selected or no Pyramid project'
-                            ' created yet. Aborting...'))
+                self.trUtf8('No current Pyramid project selected or no Pyramid'
+                            ' project created yet. Aborting...'))
             return ""
     
     def __initializeDatabase(self):
@@ -1137,17 +1188,19 @@
         try:
             projectPath = self.__projectPath()
         except PyramidNoProjectSelectedException:
-            E5MessageBox.warning(self.__ui,
+            E5MessageBox.warning(
+                self.__ui,
                 title,
-                self.trUtf8('No current Pyramid project selected or no Pyramid project'
-                            ' created yet. Aborting...'))
+                self.trUtf8('No current Pyramid project selected or no Pyramid'
+                            ' project created yet. Aborting...'))
             return
         
         cmd = self.__getInitDbCommand()
         args = []
         args.append("development.ini")
         
-        dia = PyramidDialog(title,
+        dia = PyramidDialog(
+            title,
             msgSuccess=self.trUtf8("Database initialized successfully."))
         res = dia.startProcess(cmd, args, projectPath)
         if res:
@@ -1165,10 +1218,11 @@
         try:
             projectPath = self.__projectPath()
         except PyramidNoProjectSelectedException:
-            E5MessageBox.warning(self.__ui,
+            E5MessageBox.warning(
+                self.__ui,
                 title,
-                self.trUtf8('No current Pyramid project selected or no Pyramid project'
-                            ' created yet. Aborting...'))
+                self.trUtf8('No current Pyramid project selected or no Pyramid'
+                            ' project created yet. Aborting...'))
             return
         
         url, ok = QInputDialog.getText(
@@ -1198,10 +1252,11 @@
         try:
             projectPath = self.__projectPath()
         except PyramidNoProjectSelectedException:
-            E5MessageBox.warning(self.__ui,
+            E5MessageBox.warning(
+                self.__ui,
                 title,
-                self.trUtf8('No current Pyramid project selected or no Pyramid project'
-                            ' created yet. Aborting...'))
+                self.trUtf8('No current Pyramid project selected or no Pyramid'
+                            ' project created yet. Aborting...'))
             return
         
         from .PyramidRoutesDialog import PyramidRoutesDialog
@@ -1219,10 +1274,11 @@
         try:
             projectPath = self.__projectPath()
         except PyramidNoProjectSelectedException:
-            E5MessageBox.warning(self.__ui,
+            E5MessageBox.warning(
+                self.__ui,
                 title,
-                self.trUtf8('No current Pyramid project selected or no Pyramid project'
-                            ' created yet. Aborting...'))
+                self.trUtf8('No current Pyramid project selected or no Pyramid'
+                            ' project created yet. Aborting...'))
             return
         
         cmd = self.getPyramidCommand("ptweens")
@@ -1314,10 +1370,11 @@
         try:
             projectPath = self.__projectPath()
         except PyramidNoProjectSelectedException:
-            E5MessageBox.warning(self.__ui,
+            E5MessageBox.warning(
+                self.__ui,
                 title,
-                self.trUtf8('No current Pyramid project selected or no Pyramid project'
-                            ' created yet. Aborting...'))
+                self.trUtf8('No current Pyramid project selected or no Pyramid'
+                            ' project created yet. Aborting...'))
             return
 
         config = configparser.ConfigParser()
@@ -1347,7 +1404,8 @@
         args.append("setup.py")
         args.append("extract_messages")
         
-        dia = PyramidDialog(title,
+        dia = PyramidDialog(
+            title,
             msgSuccess=self.trUtf8("\nMessages extracted successfully."))
         res = dia.startProcess(cmd, args, projectPath)
         if res:
@@ -1360,14 +1418,16 @@
         
         @param code language code of the new language (string)
         """
-        title = self.trUtf8("Initializing message catalog for '{0}'").format(code)
+        title = self.trUtf8("Initializing message catalog for '{0}'")\
+            .format(code)
         try:
             projectPath = self.__projectPath()
         except PyramidNoProjectSelectedException:
-            E5MessageBox.warning(self.__ui,
+            E5MessageBox.warning(
+                self.__ui,
                 title,
-                self.trUtf8('No current Pyramid project selected or no Pyramid project'
-                            ' created yet. Aborting...'))
+                self.trUtf8('No current Pyramid project selected or no Pyramid'
+                            ' project created yet. Aborting...'))
             return
         
         cmd = self.getPythonCommand()
@@ -1377,8 +1437,10 @@
         args.append("-l")
         args.append(code)
         
-        dia = PyramidDialog(title,
-            msgSuccess=self.trUtf8("\nMessage catalog initialized successfully."))
+        dia = PyramidDialog(
+            title,
+            msgSuccess=self.trUtf8("\nMessage catalog initialized"
+                                   " successfully."))
         res = dia.startProcess(cmd, args, projectPath)
         if res:
             dia.exec_()
@@ -1397,10 +1459,11 @@
         try:
             projectPath = self.__projectPath()
         except PyramidNoProjectSelectedException:
-            E5MessageBox.warning(self.__ui,
+            E5MessageBox.warning(
+                self.__ui,
                 title,
-                self.trUtf8('No current Pyramid project selected or no Pyramid project'
-                            ' created yet. Aborting...'))
+                self.trUtf8('No current Pyramid project selected or no Pyramid'
+                            ' project created yet. Aborting...'))
             return
         
         cmd = self.getPythonCommand()
@@ -1408,8 +1471,10 @@
         args.append("setup.py")
         args.append("compile_catalog")
         
-        dia = PyramidDialog(title,
-            msgSuccess=self.trUtf8("\nMessage catalogs compiled successfully."))
+        dia = PyramidDialog(
+            title,
+            msgSuccess=self.trUtf8("\nMessage catalogs compiled"
+                                   " successfully."))
         res = dia.startProcess(cmd, args, projectPath)
         if res:
             dia.exec_()
@@ -1430,15 +1495,17 @@
         try:
             projectPath = self.__projectPath()
         except PyramidNoProjectSelectedException:
-            E5MessageBox.warning(self.__ui,
+            E5MessageBox.warning(
+                self.__ui,
                 title,
-                self.trUtf8('No current Pyramid project selected or no Pyramid project'
-                            ' created yet. Aborting...'))
+                self.trUtf8('No current Pyramid project selected or no Pyramid'
+                            ' project created yet. Aborting...'))
             return
         
         argsLists = []
         
-        for filename in self.__normalizeList(self.__projectFilteredList(filenames)):
+        for filename in self.__normalizeList(
+                self.__projectFilteredList(filenames)):
             locale = self.__getLocale(filename)
             if locale:
                 args = []
@@ -1450,13 +1517,16 @@
                 argsLists.append(args)
         
         if len(argsLists) == 0:
-            E5MessageBox.warning(self.__ui,
+            E5MessageBox.warning(
+                self.__ui,
                 title,
                 self.trUtf8('No locales detected. Aborting...'))
             return
         
-        dia = PyramidDialog(title,
-            msgSuccess=self.trUtf8("\nMessage catalogs compiled successfully."))
+        dia = PyramidDialog(
+            title,
+            msgSuccess=self.trUtf8("\nMessage catalogs compiled"
+                                   " successfully."))
         res = dia.startBatchProcesses(argsLists, projectPath)
         if res:
             dia.exec_()
@@ -1477,10 +1547,11 @@
         try:
             projectPath = self.__projectPath()
         except PyramidNoProjectSelectedException:
-            E5MessageBox.warning(self.__ui,
+            E5MessageBox.warning(
+                self.__ui,
                 title,
-                self.trUtf8('No current Pyramid project selected or no Pyramid project'
-                            ' created yet. Aborting...'))
+                self.trUtf8('No current Pyramid project selected or no Pyramid'
+                            ' project created yet. Aborting...'))
             return
         
         cmd = self.getPythonCommand()
@@ -1488,7 +1559,8 @@
         args.append("setup.py")
         args.append("update_catalog")
         
-        dia = PyramidDialog(title,
+        dia = PyramidDialog(
+            title,
             msgSuccess=self.trUtf8("\nMessage catalogs updated successfully."))
         res = dia.startProcess(cmd, args, projectPath)
         if res:
@@ -1504,15 +1576,17 @@
         try:
             projectPath = self.__projectPath()
         except PyramidNoProjectSelectedException:
-            E5MessageBox.warning(self.__ui,
+            E5MessageBox.warning(
+                self.__ui,
                 title,
-                self.trUtf8('No current Pyramid project selected or no Pyramid project'
-                            ' created yet. Aborting...'))
+                self.trUtf8('No current Pyramid project selected or no Pyramid'
+                            ' project created yet. Aborting...'))
             return
         
         argsLists = []
         
-        for filename in self.__normalizeList(self.__projectFilteredList(filenames)):
+        for filename in self.__normalizeList(
+                self.__projectFilteredList(filenames)):
             locale = self.__getLocale(filename)
             if locale:
                 args = []
@@ -1524,12 +1598,14 @@
                 argsLists.append(args)
         
         if len(argsLists) == 0:
-            E5MessageBox.warning(self.__ui,
+            E5MessageBox.warning(
+                self.__ui,
                 title,
                 self.trUtf8('No locales detected. Aborting...'))
             return
         
-        dia = PyramidDialog(title,
+        dia = PyramidDialog(
+            title,
             msgSuccess=self.trUtf8("\nMessage catalogs updated successfully."))
         res = dia.startBatchProcesses(argsLists, projectPath)
         if res:
@@ -1549,7 +1625,9 @@
                 wd = ""
             started, pid = QProcess.startDetached(editor, [poFile], wd)
             if not started:
-                E5MessageBox.critical(None,
+                E5MessageBox.critical(
+                    None,
                     self.trUtf8('Process Generation Error'),
-                    self.trUtf8('The translations editor process ({0}) could not'
-                                ' be started.').format(os.path.basename(editor)))
+                    self.trUtf8('The translations editor process ({0}) could'
+                                ' not be started.').format(
+                        os.path.basename(editor)))

eric ide

mercurial