--- a/ProjectDjango/Project.py Sun Oct 13 18:31:28 2013 +0200 +++ b/ProjectDjango/Project.py Fri Oct 25 18:50:04 2013 +0200 @@ -18,7 +18,8 @@ import re from PyQt4.QtCore import QObject, QTimer, QUrl, QFileInfo -from PyQt4.QtGui import QMenu, QInputDialog, QLineEdit, QDesktopServices, QDialog +from PyQt4.QtGui import QMenu, QInputDialog, QLineEdit, QDesktopServices, \ + QDialog from PyQt4.QtCore import QProcess as QProcessPyQt from E5Gui.E5Application import e5App @@ -47,8 +48,8 @@ """ def start(self, cmd, args=[], mode=QProcessPyQt.ReadWrite): """ - Starts the given program (cmd) in a new process, if none is already - running, passing the command line arguments in argss. + Static method to start the given program (cmd) in a new process, if + none is already running, passing the command line arguments in args. @param cmd start the given program cmd (string) @keyparam args list of parameters (list of strings) @@ -62,8 +63,8 @@ @staticmethod def startDetached(cmd, args=[], path=''): """ - Starts the given program (cmd) in a new process, if none is already - running, passing the command line arguments in argss. + Static method to start the given program (cmd) in a new process, if + none is already running, passing the command line arguments in args. @param cmd start the given program cmd (string) @keyparam args list of parameters (list of strings) @@ -112,10 +113,11 @@ """ self.actions = [] - self.selectSiteAct = E5Action(self.trUtf8('Current Project'), - "", - 0, 0, - self, 'django_current_project') + self.selectSiteAct = E5Action( + self.trUtf8('Current Project'), + "", + 0, 0, + self, 'django_current_project') self.selectSiteAct.setStatusTip(self.trUtf8( 'Selects the current project')) self.selectSiteAct.setWhatsThis(self.trUtf8( @@ -131,24 +133,26 @@ ## start actions below ## ############################## - self.startProjectAct = E5Action(self.trUtf8('Start Project'), - self.trUtf8('Start &Project'), - 0, 0, - self, 'django_start_project') + self.startProjectAct = E5Action( + self.trUtf8('Start Project'), + self.trUtf8('Start &Project'), + 0, 0, + self, 'django_start_project') self.startProjectAct.setStatusTip(self.trUtf8( 'Starts a new Django project')) self.startProjectAct.setWhatsThis(self.trUtf8( """<b>Start Project</b>""" - """<p>Starts a new Django project using "django-admin.py startproject".</p>""" + """<p>Starts a new Django project using "django-admin.py""" + """ startproject".</p>""" )) self.startProjectAct.triggered[()].connect(self.__startProject) self.actions.append(self.startProjectAct) self.startGlobalApplicationAct = E5Action( - self.trUtf8('Start Application (global)'), - self.trUtf8('Start Application (&global)'), - 0, 0, - self, 'django_start_global_application') + self.trUtf8('Start Application (global)'), + self.trUtf8('Start Application (&global)'), + 0, 0, + self, 'django_start_global_application') self.startGlobalApplicationAct.setStatusTip(self.trUtf8( 'Starts a new global Django application')) self.startGlobalApplicationAct.setWhatsThis(self.trUtf8( @@ -161,10 +165,10 @@ self.actions.append(self.startGlobalApplicationAct) self.startLocalApplicationAct = E5Action( - self.trUtf8('Start Application (local)'), - self.trUtf8('Start Application (&local)'), - 0, 0, - self, 'django_start_local_application') + self.trUtf8('Start Application (local)'), + self.trUtf8('Start Application (&local)'), + 0, 0, + self, 'django_start_local_application') self.startLocalApplicationAct.setStatusTip(self.trUtf8( 'Starts a new local Django application')) self.startLocalApplicationAct.setWhatsThis(self.trUtf8( @@ -180,25 +184,29 @@ ## run actions below ## ############################## - self.runServerAct = E5Action(self.trUtf8('Run Server'), - self.trUtf8('Run &Server'), - 0, 0, - self, 'django_run_server') + self.runServerAct = E5Action( + self.trUtf8('Run Server'), + self.trUtf8('Run &Server'), + 0, 0, + self, 'django_run_server') self.runServerAct.setStatusTip(self.trUtf8( 'Starts the Django Web server')) self.runServerAct.setWhatsThis(self.trUtf8( """<b>Run Server</b>""" - """<p>Starts the Django Web server using "manage.py runserver".</p>""" + """<p>Starts the Django Web server using "manage.py""" + """ runserver".</p>""" )) self.runServerAct.triggered[()].connect(self.__runServer) self.actions.append(self.runServerAct) - self.runBrowserAct = E5Action(self.trUtf8('Run Web-Browser'), - self.trUtf8('Run &Web-Browser'), - 0, 0, - self, 'django_run_browser') + self.runBrowserAct = E5Action( + self.trUtf8('Run Web-Browser'), + self.trUtf8('Run &Web-Browser'), + 0, 0, + self, 'django_run_browser') self.runBrowserAct.setStatusTip(self.trUtf8( - 'Starts the default Web-Browser with the URL of the Django Web server')) + 'Starts the default Web-Browser with the URL of the Django Web' + ' server')) self.runBrowserAct.setWhatsThis(self.trUtf8( """<b>Run Web-Browser</b>""" """<p>Starts the default Web-Browser with the URL of the """ @@ -211,27 +219,31 @@ ## caching actions below ## ############################## - self.createCacheTableAct = E5Action(self.trUtf8('Create Cache Tables'), - self.trUtf8('C&reate Cache Tables'), - 0, 0, - self, 'django_create_cache_tables') + self.createCacheTableAct = E5Action( + self.trUtf8('Create Cache Tables'), + self.trUtf8('C&reate Cache Tables'), + 0, 0, + self, 'django_create_cache_tables') self.createCacheTableAct.setStatusTip(self.trUtf8( 'Creates the tables needed to use the SQL cache backend')) self.createCacheTableAct.setWhatsThis(self.trUtf8( """<b>Create Cache Tables</b>""" - """<p>Creates the tables needed to use the SQL cache backend.</p>""" + """<p>Creates the tables needed to use the SQL cache""" + """ backend.</p>""" )) - self.createCacheTableAct.triggered[()].connect(self.__createCacheTables) + self.createCacheTableAct.triggered[()].connect( + self.__createCacheTables) self.actions.append(self.createCacheTableAct) ############################## ## help action below ## ############################## - self.helpAct = E5Action(self.trUtf8('Help'), - self.trUtf8('&Help'), - 0, 0, - self, 'django_help') + self.helpAct = E5Action( + self.trUtf8('Help'), + self.trUtf8('&Help'), + 0, 0, + self, 'django_help') self.helpAct.setStatusTip(self.trUtf8( 'Shows the Django help index')) self.helpAct.setWhatsThis(self.trUtf8( @@ -245,10 +257,11 @@ ## about action below ## ############################## - self.aboutDjangoAct = E5Action(self.trUtf8('About Django'), - self.trUtf8('About D&jango'), - 0, 0, - self, 'django_about') + self.aboutDjangoAct = E5Action( + self.trUtf8('About Django'), + self.trUtf8('About D&jango'), + 0, 0, + self, 'django_about') self.aboutDjangoAct.setStatusTip(self.trUtf8( 'Shows some information about Django')) self.aboutDjangoAct.setWhatsThis(self.trUtf8( @@ -269,10 +282,11 @@ """ Private method to define the database related actions. """ - self.syncDatabaseAct = E5Action(self.trUtf8('Synchronize'), - self.trUtf8('&Synchronize'), - 0, 0, - self, 'django_database_syncdb') + self.syncDatabaseAct = E5Action( + self.trUtf8('Synchronize'), + self.trUtf8('&Synchronize'), + 0, 0, + self, 'django_database_syncdb') self.syncDatabaseAct.setStatusTip(self.trUtf8( 'Synchronizes the database')) self.syncDatabaseAct.setWhatsThis(self.trUtf8( @@ -282,12 +296,14 @@ self.syncDatabaseAct.triggered[()].connect(self.__databaseSynchronize) self.actions.append(self.syncDatabaseAct) - self.inspectDatabaseAct = E5Action(self.trUtf8('Introspect'), - self.trUtf8('&Introspect'), - 0, 0, - self, 'django_database_inspect') + self.inspectDatabaseAct = E5Action( + self.trUtf8('Introspect'), + self.trUtf8('&Introspect'), + 0, 0, + self, 'django_database_inspect') self.inspectDatabaseAct.setStatusTip(self.trUtf8( - 'Introspects the database tables and outputs a Django model module')) + 'Introspects the database tables and outputs a Django model' + ' module')) self.inspectDatabaseAct.setWhatsThis(self.trUtf8( """<b>Introspect</b>""" """<p>Introspects the database tables and outputs a """ @@ -296,12 +312,14 @@ self.inspectDatabaseAct.triggered[()].connect(self.__databaseInspect) self.actions.append(self.inspectDatabaseAct) - self.flushDatabaseAct = E5Action(self.trUtf8('Flush'), - self.trUtf8('&Flush'), - 0, 0, - self, 'django_database_flush') + self.flushDatabaseAct = E5Action( + self.trUtf8('Flush'), + self.trUtf8('&Flush'), + 0, 0, + self, 'django_database_flush') self.flushDatabaseAct.setStatusTip(self.trUtf8( - 'Returns all database tables to the state just after their installation')) + 'Returns all database tables to the state just after their' + ' installation')) self.flushDatabaseAct.setWhatsThis(self.trUtf8( """<b>Flush</b>""" """<p>Returns all database tables to the state """ @@ -310,10 +328,11 @@ self.flushDatabaseAct.triggered[()].connect(self.__databaseFlush) self.actions.append(self.flushDatabaseAct) - self.databaseClientAct = E5Action(self.trUtf8('Start Client Console'), - self.trUtf8('Start &Client Console'), - 0, 0, - self, 'django_database_client') + self.databaseClientAct = E5Action( + self.trUtf8('Start Client Console'), + self.trUtf8('Start &Client Console'), + 0, 0, + self, 'django_database_client') self.databaseClientAct.setStatusTip(self.trUtf8( 'Starts a console window for the database client')) self.databaseClientAct.setWhatsThis(self.trUtf8( @@ -327,12 +346,14 @@ """ Private method to define the database SQL related actions. """ - self.databaseSqlCreateTablesAct = E5Action(self.trUtf8('Create Tables'), - self.trUtf8('Create &Tables'), - 0, 0, - self, 'django_database_sql_create_tables') + self.databaseSqlCreateTablesAct = E5Action( + self.trUtf8('Create Tables'), + self.trUtf8('Create &Tables'), + 0, 0, + self, 'django_database_sql_create_tables') self.databaseSqlCreateTablesAct.setStatusTip(self.trUtf8( - 'Prints the CREATE TABLE SQL statements for one or more applications')) + 'Prints the CREATE TABLE SQL statements for one or more' + ' applications')) self.databaseSqlCreateTablesAct.setWhatsThis(self.trUtf8( """<b>Create Tables</b>""" """<p>Prints the CREATE TABLE SQL statements for one or """ @@ -342,12 +363,14 @@ self.__databaseSqlCreateTables) self.actions.append(self.databaseSqlCreateTablesAct) - self.databaseSqlCreateIndexesAct = E5Action(self.trUtf8('Create Indexes'), - self.trUtf8('Create &Indexes'), - 0, 0, - self, 'django_database_sql_create_indexes') + self.databaseSqlCreateIndexesAct = E5Action( + self.trUtf8('Create Indexes'), + self.trUtf8('Create &Indexes'), + 0, 0, + self, 'django_database_sql_create_indexes') self.databaseSqlCreateIndexesAct.setStatusTip(self.trUtf8( - 'Prints the CREATE INDEX SQL statements for one or more applications')) + 'Prints the CREATE INDEX SQL statements for one or more' + ' applications')) self.databaseSqlCreateIndexesAct.setWhatsThis(self.trUtf8( """<b>Create Indexes</b>""" """<p>Prints the CREATE INDEX SQL statements for one or """ @@ -357,12 +380,14 @@ self.__databaseSqlCreateIndexes) self.actions.append(self.databaseSqlCreateIndexesAct) - self.databaseSqlCreateEverythingAct = E5Action(self.trUtf8('Create Everything'), - self.trUtf8('Create &Everything'), - 0, 0, - self, 'django_database_sql_create_everything') + self.databaseSqlCreateEverythingAct = E5Action( + self.trUtf8('Create Everything'), + self.trUtf8('Create &Everything'), + 0, 0, + self, 'django_database_sql_create_everything') self.databaseSqlCreateEverythingAct.setStatusTip(self.trUtf8( - 'Prints the CREATE ... SQL statements for one or more applications')) + 'Prints the CREATE ... SQL statements for one or more' + ' applications')) self.databaseSqlCreateEverythingAct.setWhatsThis(self.trUtf8( """<b>Create Everything</b>""" """<p>Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL """ @@ -372,10 +397,11 @@ self.__databaseSqlCreateEverything) self.actions.append(self.databaseSqlCreateEverythingAct) - self.databaseSqlCustomAct = E5Action(self.trUtf8('Custom Statements'), - self.trUtf8('&Custom Statements'), - 0, 0, - self, 'django_database_sql_custom') + self.databaseSqlCustomAct = E5Action( + self.trUtf8('Custom Statements'), + self.trUtf8('&Custom Statements'), + 0, 0, + self, 'django_database_sql_custom') self.databaseSqlCustomAct.setStatusTip(self.trUtf8( 'Prints the custom table modifying SQL statements for ' 'one or more applications')) @@ -388,10 +414,11 @@ self.__databaseSqlCustom) self.actions.append(self.databaseSqlCustomAct) - self.databaseSqlDropTablesAct = E5Action(self.trUtf8('Drop Tables'), - self.trUtf8('&Drop Tables'), - 0, 0, - self, 'django_database_sql_drop_tables') + self.databaseSqlDropTablesAct = E5Action( + self.trUtf8('Drop Tables'), + self.trUtf8('&Drop Tables'), + 0, 0, + self, 'django_database_sql_drop_tables') self.databaseSqlDropTablesAct.setStatusTip(self.trUtf8( 'Prints the DROP TABLE SQL statements for ' 'one or more applications')) @@ -404,26 +431,28 @@ self.__databaseSqlDropTables) self.actions.append(self.databaseSqlDropTablesAct) - self.databaseSqlFlushAct = E5Action(self.trUtf8('Flush Database'), - self.trUtf8('&Flush Database'), - 0, 0, - self, 'django_database_sql_flush_database') + self.databaseSqlFlushAct = E5Action( + self.trUtf8('Flush Database'), + self.trUtf8('&Flush Database'), + 0, 0, + self, 'django_database_sql_flush_database') self.databaseSqlFlushAct.setStatusTip(self.trUtf8( - 'Prints a list of statements to return all database tables to the state ' - 'just after their installation')) + 'Prints a list of statements to return all database tables to the' + ' state just after their installation')) self.databaseSqlFlushAct.setWhatsThis(self.trUtf8( """<b>Flush Database</b>""" - """<p>Prints a list of statements to return all database tables to """ - """the state just after their installation.</p>""" + """<p>Prints a list of statements to return all database tables""" + """ to the state just after their installation.</p>""" )) self.databaseSqlFlushAct.triggered[()].connect( self.__databaseSqlFlushDatabase) self.actions.append(self.databaseSqlFlushAct) - self.databaseSqlResetSeqAct = E5Action(self.trUtf8('Reset Sequences'), - self.trUtf8('Reset &Sequences'), - 0, 0, - self, 'django_database_sql_reset_sequences') + self.databaseSqlResetSeqAct = E5Action( + self.trUtf8('Reset Sequences'), + self.trUtf8('Reset &Sequences'), + 0, 0, + self, 'django_database_sql_reset_sequences') self.databaseSqlResetSeqAct.setStatusTip(self.trUtf8( 'Prints the SQL statements for resetting sequences for ' 'one or more applications')) @@ -440,10 +469,11 @@ """ Private method to define the tool actions. """ - self.diffSettingsAct = E5Action(self.trUtf8('Diff Settings'), - self.trUtf8('&Diff Settings'), - 0, 0, - self, 'django_tools_diffsettings') + self.diffSettingsAct = E5Action( + self.trUtf8('Diff Settings'), + self.trUtf8('&Diff Settings'), + 0, 0, + self, 'django_tools_diffsettings') self.diffSettingsAct.setStatusTip(self.trUtf8( 'Shows the modification made to the settings')) self.diffSettingsAct.setWhatsThis(self.trUtf8( @@ -453,10 +483,11 @@ self.diffSettingsAct.triggered[()].connect(self.__diffSettings) self.actions.append(self.diffSettingsAct) - self.cleanupAct = E5Action(self.trUtf8('Cleanup'), - self.trUtf8('&Cleanup'), - 0, 0, - self, 'django_tools_cleanup') + self.cleanupAct = E5Action( + self.trUtf8('Cleanup'), + self.trUtf8('&Cleanup'), + 0, 0, + self, 'django_tools_cleanup') self.cleanupAct.setStatusTip(self.trUtf8( 'Cleans out old data from the database')) self.cleanupAct.setWhatsThis(self.trUtf8( @@ -466,10 +497,11 @@ self.cleanupAct.triggered[()].connect(self.__cleanup) self.actions.append(self.cleanupAct) - self.validateAct = E5Action(self.trUtf8('Validate'), - self.trUtf8('&Validate'), - 0, 0, - self, 'django_tools_validate') + self.validateAct = E5Action( + self.trUtf8('Validate'), + self.trUtf8('&Validate'), + 0, 0, + self, 'django_tools_validate') self.validateAct.setStatusTip(self.trUtf8( 'Validates all installed models')) self.validateAct.setWhatsThis(self.trUtf8( @@ -479,10 +511,11 @@ self.validateAct.triggered[()].connect(self.__validate) self.actions.append(self.validateAct) - self.runPythonShellAct = E5Action(self.trUtf8('Start Python Console'), - self.trUtf8('Start &Python Console'), - 0, 0, - self, 'django_tools_pythonconsole') + self.runPythonShellAct = E5Action( + self.trUtf8('Start Python Console'), + self.trUtf8('Start &Python Console'), + 0, 0, + self, 'django_tools_pythonconsole') self.runPythonShellAct.setStatusTip(self.trUtf8( 'Starts a Python interactive interpreter')) self.runPythonShellAct.setWhatsThis(self.trUtf8( @@ -496,10 +529,11 @@ """ Private method to define the testing actions. """ - self.dumpDataAct = E5Action(self.trUtf8('Dump Data'), - self.trUtf8('&Dump Data'), - 0, 0, - self, 'django_tools_dumpdata') + self.dumpDataAct = E5Action( + self.trUtf8('Dump Data'), + self.trUtf8('&Dump Data'), + 0, 0, + self, 'django_tools_dumpdata') self.dumpDataAct.setStatusTip(self.trUtf8( 'Dump the database data to a fixture')) self.dumpDataAct.setWhatsThis(self.trUtf8( @@ -509,10 +543,11 @@ self.dumpDataAct.triggered[()].connect(self.__dumpData) self.actions.append(self.dumpDataAct) - self.loadDataAct = E5Action(self.trUtf8('Load Data'), - self.trUtf8('&Load Data'), - 0, 0, - self, 'django_tools_loaddata') + self.loadDataAct = E5Action( + self.trUtf8('Load Data'), + self.trUtf8('&Load Data'), + 0, 0, + self, 'django_tools_loaddata') self.loadDataAct.setStatusTip(self.trUtf8( 'Load data from fixture files')) self.loadDataAct.setWhatsThis(self.trUtf8( @@ -522,10 +557,11 @@ self.loadDataAct.triggered[()].connect(self.__loadData) self.actions.append(self.loadDataAct) - self.runTestAct = E5Action(self.trUtf8('Run Testsuite'), - self.trUtf8('Run &Testsuite'), - 0, 0, - self, 'django_tools_run_test') + self.runTestAct = E5Action( + self.trUtf8('Run Testsuite'), + self.trUtf8('Run &Testsuite'), + 0, 0, + self, 'django_tools_run_test') self.runTestAct.setStatusTip(self.trUtf8( 'Run the test suite for applications or the whole site')) self.runTestAct.setWhatsThis(self.trUtf8( @@ -535,15 +571,17 @@ self.runTestAct.triggered[()].connect(self.__runTestSuite) self.actions.append(self.runTestAct) - self.runTestServerAct = E5Action(self.trUtf8('Run Testserver'), - self.trUtf8('Run Test&server'), - 0, 0, - self, 'django_tools_run_test_server') + self.runTestServerAct = E5Action( + self.trUtf8('Run Testserver'), + self.trUtf8('Run Test&server'), + 0, 0, + self, 'django_tools_run_test_server') self.runTestServerAct.setStatusTip(self.trUtf8( 'Run a development server with data from a set of fixtures')) self.runTestServerAct.setWhatsThis(self.trUtf8( """<b>Run Testserver</b>""" - """<p>Run a development server with data from a set of fixtures.</p>""" + """<p>Run a development server with data from a set of""" + """ fixtures.</p>""" )) self.runTestServerAct.triggered[()].connect(self.__runTestServer) self.actions.append(self.runTestServerAct) @@ -552,10 +590,11 @@ """ Private method to define the authorization actions. """ - self.changePasswordAct = E5Action(self.trUtf8('Change Password'), - self.trUtf8('Change &Password'), - 0, 0, - self, 'django_auth_changepassword') + self.changePasswordAct = E5Action( + self.trUtf8('Change Password'), + self.trUtf8('Change &Password'), + 0, 0, + self, 'django_auth_changepassword') self.changePasswordAct.setStatusTip(self.trUtf8( 'Change the password of a user')) self.changePasswordAct.setWhatsThis(self.trUtf8( @@ -565,10 +604,11 @@ self.changePasswordAct.triggered[()].connect(self.__changePassword) self.actions.append(self.changePasswordAct) - self.createSuperUserAct = E5Action(self.trUtf8('Create Superuser'), - self.trUtf8('Create &Superuser'), - 0, 0, - self, 'django_auth_createsuperuser') + self.createSuperUserAct = E5Action( + self.trUtf8('Create Superuser'), + self.trUtf8('Create &Superuser'), + 0, 0, + self, 'django_auth_createsuperuser') self.createSuperUserAct.setStatusTip(self.trUtf8( 'Create a superuser account')) self.createSuperUserAct.setWhatsThis(self.trUtf8( @@ -582,10 +622,11 @@ """ Private method to define the session actions. """ - self.clearSessionsAct = E5Action(self.trUtf8('Clear Sessions'), - self.trUtf8('Clear &Sessions'), - 0, 0, - self, 'django_session_clearsessions') + self.clearSessionsAct = E5Action( + self.trUtf8('Clear Sessions'), + self.trUtf8('Clear &Sessions'), + 0, 0, + self, 'django_session_clearsessions') self.clearSessionsAct.setStatusTip(self.trUtf8( 'Clear expired sessions')) self.clearSessionsAct.setWhatsThis(self.trUtf8( @@ -750,9 +791,11 @@ editor = self.__plugin.getPreferences("TranslationsEditor") try: if editor: - self.__translationsBrowser.addHookMethodAndMenuEntry("open", + self.__translationsBrowser.addHookMethodAndMenuEntry( + "open", self.openPOEditor, - self.trUtf8("Open with {0}").format(os.path.basename(editor))) + self.trUtf8("Open with {0}").format( + os.path.basename(editor))) else: self.__translationsBrowser.removeHookMethod("open") except KeyError: @@ -766,26 +809,34 @@ if self.__e5project.getProjectType() == "Django": self.__formsBrowser = \ e5App().getObject("ProjectBrowser").getProjectBrowser("forms") - self.__formsBrowser.addHookMethodAndMenuEntry("newForm", + self.__formsBrowser.addHookMethodAndMenuEntry( + "newForm", self.newForm, self.trUtf8("New template...")) self.__e5project.projectLanguageAddedByCode.connect( self.__projectLanguageAdded) self.__translationsBrowser = \ - e5App().getObject("ProjectBrowser").getProjectBrowser("translations") - self.__translationsBrowser.addHookMethodAndMenuEntry("generateAll", + e5App().getObject("ProjectBrowser")\ + .getProjectBrowser("translations") + 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( + "generateSelected", + self.updateSelectedCatalogs, + self.trUtf8("Update selected catalogs")) self.__translationsBrowser.addHookMethodAndMenuEntry( "generateAllWithObsolete", self.updateCatalogsWithObsolete, self.trUtf8("Update all catalogs (with obsolete)")) self.__translationsBrowser.addHookMethodAndMenuEntry( - "generateSelectedWithObsolete", self.updateSelectedCatalogsWithObsolete, + "generateSelectedWithObsolete", + self.updateSelectedCatalogsWithObsolete, self.trUtf8("Update selected catalogs (with obsolete)")) - self.__translationsBrowser.addHookMethodAndMenuEntry("releaseAll", + self.__translationsBrowser.addHookMethodAndMenuEntry( + "releaseAll", self.compileCatalogs, self.trUtf8("Compile all catalogs")) - self.__translationsBrowser.addHookMethodAndMenuEntry("releaseSelected", + self.__translationsBrowser.addHookMethodAndMenuEntry( + "releaseSelected", self.compileSelectedCatalogs, self.trUtf8("Compile selected catalogs")) @@ -803,12 +854,18 @@ self.__e5project.projectLanguageAddedByCode.disconnect( self.__projectLanguageAdded) - self.__translationsBrowser.removeHookMethod("generateAll") - self.__translationsBrowser.removeHookMethod("generateSelected") - self.__translationsBrowser.removeHookMethod("generateAllWithObsolete") - self.__translationsBrowser.removeHookMethod("generateSelectedWithObsolete") - self.__translationsBrowser.removeHookMethod("releaseAll") - self.__translationsBrowser.removeHookMethod("releaseSelected") + self.__translationsBrowser.removeHookMethod( + "generateAll") + self.__translationsBrowser.removeHookMethod( + "generateSelected") + self.__translationsBrowser.removeHookMethod( + "generateAllWithObsolete") + self.__translationsBrowser.removeHookMethod( + "generateSelectedWithObsolete") + self.__translationsBrowser.removeHookMethod( + "releaseAll") + self.__translationsBrowser.removeHookMethod( + "releaseSelected") try: self.__translationsBrowser.removeHookMethod("open") except KeyError: @@ -843,7 +900,8 @@ 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?"), icon=E5MessageBox.Warning) @@ -859,9 +917,11 @@ f.write(' <head>\n') f.write(' <meta content="" />\n') f.write(' <title></title>\n') - f.write(' <link rel="stylesheet" type="text/css" href="style.css"/>') + f.write(' <link rel="stylesheet" type="text/css"' + ' href="style.css"/>') f.write(' <!--[if lte IE 7]>') - f.write(' <link rel="stylesheet" type="text/css" href="ie.css"/>') + f.write(' <link rel="stylesheet" type="text/css"' + ' href="ie.css"/>') f.write(' <![endif]-->') f.write(' </head>\n') f.write('\n') @@ -873,10 +933,12 @@ f.write('</html>\n') f.close() except (IOError, OSError) as e: - E5MessageBox.critical(self.__ui, + 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, str(e))) + self.trUtf8("<p>The new form file <b>{0}</b> could not be" + " created.<br> Problem: {1}</p>") + .format(fname, str(e))) return self.__e5project.appendFile(fname) @@ -900,9 +962,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 = [] @@ -960,9 +1022,9 @@ l0 = "" if variant.lower() in l0.lower() or \ "{0}.".format(variant[-1]) in l0 or \ - (variant == "Python2" and \ - "python3" not in l0.lower() and \ - "python" in l0.lower()): + (variant == "Python2" and + "python3" not in l0.lower() and + "python" in l0.lower()): variants.append(variant) break @@ -1025,7 +1087,8 @@ cmds = [ os.path.join(virtualEnv, "bin", "django-admin.py"), os.path.join(virtualEnv, "bin", "django-admin"), - os.path.join(virtualEnv, "local", "bin", "django-admin.py"), + os.path.join(virtualEnv, "local", "bin", + "django-admin.py"), os.path.join(virtualEnv, "local", "bin", "django-admin"), ] for cmd in cmds: @@ -1087,10 +1150,12 @@ version = self.getDjangoVersion() url = "http://www.djangoproject.com" - msgBox = E5MessageBox.E5MessageBox(E5MessageBox.Question, + msgBox = E5MessageBox.E5MessageBox( + E5MessageBox.Question, self.trUtf8("About Django"), self.trUtf8( - "<p>Django is a high-level Python Web framework that encourages rapid " + "<p>Django 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>" @@ -1124,8 +1189,8 @@ if procStarted: finished = process.waitForFinished(30000) if finished and process.exitCode() == 0: - output = \ - str(process.readAllStandardOutput(), ioEncoding, 'replace') + output = str(process.readAllStandardOutput(), ioEncoding, + 'replace') self.__djangoVersion = output.splitlines()[0].strip() return self.__djangoVersion @@ -1243,10 +1308,12 @@ 0, False) if ok and bool(selection): if selection == projectStr: - path, projectName = os.path.split(self.__e5project.getProjectPath()) + path, projectName = os.path.split( + self.__e5project.getProjectPath()) self.__createProject(projectName, path) elif selection == applStr: - path, applName = os.path.split(self.__e5project.getProjectPath()) + path, applName = os.path.split( + self.__e5project.getProjectPath()) self.__createApplication(applName, path) def __createProject(self, projectName, path): @@ -1269,16 +1336,18 @@ if cmd: args.append(cmd) else: - E5MessageBox.critical(self.__ui, + E5MessageBox.critical( + self.__ui, title, - self.trUtf8("""<p>The <b>django-admin.py</b> script is not in""" - """ the path. Aborting...</p>""")) + self.trUtf8("""<p>The <b>django-admin.py</b> script is""" + """ not in the path. Aborting...</p>""")) return args.append("startproject") args.append(projectName) - dia = DjangoDialog(title, + dia = DjangoDialog( + title, msgSuccess=self.trUtf8("Django project created successfully.")) res = dia.startProcess(args, path) if res: @@ -1289,7 +1358,8 @@ if not os.path.exists(i18nPath): os.makedirs(i18nPath) - if os.path.join(path, projectName) == self.__e5project.getProjectPath(): + if os.path.join(path, projectName) == \ + self.__e5project.getProjectPath(): self.__setCurrentSite("") else: self.__setCurrentSite(projectName) @@ -1306,7 +1376,8 @@ self.trUtf8("Enter the name of the new Django project."), QLineEdit.Normal) if ok and projectName != "": - res = self.__createProject(projectName, self.__e5project.getProjectPath()) + res = self.__createProject(projectName, + self.__e5project.getProjectPath()) if res: # search for new files and add them to the project sitePath = os.path.join(self.__e5project.getProjectPath(), @@ -1323,7 +1394,8 @@ @param applName name of the new application (string) @param path the directory where the application should be created (string) - @param isGlobal flag indicating a standalone Django application (boolean) + @param isGlobal flag indicating a standalone Django application + (boolean) @return flag indicating a successful creation (boolean) """ title = self.trUtf8("Start Django Application") @@ -1338,10 +1410,12 @@ if cmd: args.append(cmd) else: - E5MessageBox.critical(self.__ui, + E5MessageBox.critical( + self.__ui, title, - self.trUtf8("""<p>The <b>django-admin.py</b> script is not in""" - """ the path. Aborting...</p>""")) + self.trUtf8("""<p>The <b>django-admin.py</b> script""" + """ is not in the path.""" + """ Aborting...</p>""")) return else: args.append(self.__getPythonExecutable()) @@ -1353,7 +1427,8 @@ args.append("startapp") args.append(applName) - dia = DjangoDialog(title, + dia = DjangoDialog( + title, msgSuccess=self.trUtf8("Django application created successfully.")) res = dia.startProcess(args, path) if res: @@ -1367,13 +1442,16 @@ applName, ok = QInputDialog.getText( self.__ui, self.trUtf8("Start Global Django Application"), - self.trUtf8("Enter the name of the new global Django application."), + self.trUtf8("Enter the name of the new global Django" + " application."), QLineEdit.Normal) if ok and applName != "": - res = self.__createApplication(applName, self.__e5project.getProjectPath()) + res = self.__createApplication(applName, + self.__e5project.getProjectPath()) if res: # search for new files and add them to the project - appPath = os.path.join(self.__e5project.getProjectPath(), applName) + appPath = os.path.join(self.__e5project.getProjectPath(), + applName) for entry in os.walk(appPath): for fileName in entry[2]: fullName = os.path.join(entry[0], fileName) @@ -1420,8 +1498,6 @@ def __selectSite(self): """ Private method to select a site to work with. - - @return selected site (string) """ sites = self.__findSites() if len(sites) == 1: @@ -1480,7 +1556,8 @@ self.__e5project.pdata["TRANSLATIONPATTERN"] = [] else: self.__e5project.pdata["TRANSLATIONPATTERN"] = [ - os.path.join(site, "locale", "%language%", "LC_MESSAGES", "django.po") + os.path.join(site, "locale", "%language%", "LC_MESSAGES", + "django.po") ] def __site(self): @@ -1522,19 +1599,21 @@ try: if Utilities.isWindowsPlatform(): - serverProcStarted, pid = \ - QProcess.startDetached(args[0], args[1:], self.__sitePath()) + serverProcStarted, pid = QProcess.startDetached( + args[0], args[1:], self.__sitePath()) else: if self.__serverProc is not None: self.__serverProcFinished() self.__serverProc = QProcess() - self.__serverProc.finished.connect(self.__serverProcFinished) + self.__serverProc.finished.connect( + self.__serverProcFinished) self.__serverProc.setWorkingDirectory(self.__sitePath()) self.__serverProc.start(args[0], args[1:]) serverProcStarted = self.__serverProc.waitForStarted() if not serverProcStarted: - E5MessageBox.critical(None, + E5MessageBox.critical( + None, self.trUtf8('Process Generation Error'), self.trUtf8('The Django server could not be started.')) except DjangoNoSiteSelectedException: @@ -1578,10 +1657,11 @@ url = QUrl("http://{0}:{1}".format(addr, port)) res = QDesktopServices.openUrl(url) if not res: - E5MessageBox.critical(None, + E5MessageBox.critical( + None, 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())) ################################################################## ## slots below implement database related functions @@ -1603,15 +1683,18 @@ wd = self.__sitePath() started, pid = QProcess.startDetached(args[0], args[1:], wd) if not started: - E5MessageBox.critical(None, + E5MessageBox.critical( + None, self.trUtf8('Process Generation Error'), - self.trUtf8('The Django process could not be started.')) + self.trUtf8('The Django process could not be' + ' started.')) except DjangoNoSiteSelectedException: pass def __databaseInspect(self): """ - Private slot to introspect the database and output a Django model module. + Private slot to introspect the database and output a Django model + module. """ title = self.trUtf8("Introspect Database") @@ -1632,8 +1715,8 @@ def __databaseFlush(self): """ - Private slot to return all database tables to the state just after their - installation. + Private slot to return all database tables to the state just after + their installation. """ try: path = self.__sitePath() @@ -1642,9 +1725,11 @@ title = self.trUtf8("Flush Database") - res = E5MessageBox.yesNo(self.__ui, + res = E5MessageBox.yesNo( + self.__ui, title, - self.trUtf8("""Flushing the database will destroy all data. Are you sure?""")) + self.trUtf8("""Flushing the database will destroy all data.""" + """ Are you sure?""")) if res: args = [] args.append(self.__getPythonExecutable()) @@ -1652,8 +1737,10 @@ args.append("flush") args.append("--noinput") - dia = DjangoDialog(title, - msgSuccess=self.trUtf8("Database tables flushed successfully.")) + dia = DjangoDialog( + title, + msgSuccess=self.trUtf8("Database tables flushed" + " successfully.")) res = dia.startProcess(args, path) if res: dia.exec_() @@ -1674,9 +1761,11 @@ wd = self.__sitePath() started, pid = QProcess.startDetached(args[0], args[1:], wd) if not started: - E5MessageBox.critical(None, + E5MessageBox.critical( + None, self.trUtf8('Process Generation Error'), - self.trUtf8('The Django process could not be started.')) + self.trUtf8('The Django process could not be' + ' started.')) except DjangoNoSiteSelectedException: pass @@ -1809,7 +1898,8 @@ except DjangoNoSiteSelectedException: return - dia = DjangoDialog(title, + dia = DjangoDialog( + title, msgSuccess=self.trUtf8("Database cleaned up successfully.")) res = dia.startProcess(args, path) if res: @@ -1859,9 +1949,11 @@ wd = self.__sitePath() started, pid = QProcess.startDetached(args[0], args[1:], wd) if not started: - E5MessageBox.critical(None, + E5MessageBox.critical( + None, self.trUtf8('Process Generation Error'), - self.trUtf8('The Django process could not be started.')) + self.trUtf8('The Django process could not be' + ' started.')) except DjangoNoSiteSelectedException: pass @@ -1883,7 +1975,8 @@ tblStr, ok = QInputDialog.getText( self.__ui, title, - self.trUtf8("Enter the names of the cache tables separated by spaces."), + self.trUtf8("Enter the names of the cache tables separated by" + " spaces."), QLineEdit.Normal) if ok and tblStr != "": tableNames = tblStr.split() @@ -1894,7 +1987,8 @@ args.append("createcachetable") args += tableNames - dia = DjangoDialog(title, + dia = DjangoDialog( + title, msgSuccess=self.trUtf8("Cache tables created successfully.")) res = dia.startProcess(args, wd) if res: @@ -1937,8 +2031,8 @@ elif format == "yaml": fileFilters = self.trUtf8("YAML Files (*.yaml)") - dia = DjangoDialog(title, fixed=True, linewrap=False, - saveFilters=fileFilters) + dia = DjangoDialog( + title, fixed=True, linewrap=False, saveFilters=fileFilters) res = dia.startProcess(args, wd, showCommand=False) if res: dia.exec_() @@ -1991,13 +2085,15 @@ started, pid = QProcess.startDetached(args[0], args[1:], wd) if not started: - E5MessageBox.critical(None, + E5MessageBox.critical( + None, self.trUtf8('Process Generation Error'), self.trUtf8('The Django process could not be started.')) def __runTestServer(self): """ - Private slot to run a development server with data from a set of fixtures. + Private slot to run a development server with data from a set of + fixtures. """ consoleCmd = self.__isSpawningConsole( self.__plugin.getPreferences("ConsoleCommand"))[1] @@ -2021,21 +2117,26 @@ try: if Utilities.isWindowsPlatform(): - serverProcStarted, pid = \ - QProcess.startDetached(args[0], args[1:], self.__sitePath()) + serverProcStarted, pid = QProcess.startDetached( + args[0], args[1:], self.__sitePath()) else: if self.__testServerProc is not None: self.__testServerProcFinished() self.__testServerProc = QProcess() - self.__testServerProc.finished.connect(self.__serverProcFinished) - self.__testServerProc.setWorkingDirectory(self.__sitePath()) + self.__testServerProc.finished.connect( + self.__serverProcFinished) + self.__testServerProc.setWorkingDirectory( + self.__sitePath()) self.__testServerProc.start(args[0], args[1:]) - serverProcStarted = self.__testServerProc.waitForStarted() + serverProcStarted = \ + self.__testServerProc.waitForStarted() if not serverProcStarted: - E5MessageBox.critical(None, + E5MessageBox.critical( + None, self.trUtf8('Process Generation Error'), - self.trUtf8('The Django test server could not be started.')) + self.trUtf8('The Django test server could not be' + ' started.')) except DjangoNoSiteSelectedException: pass @@ -2075,11 +2176,14 @@ args.append(userName) try: wd = self.__sitePath() - started, pid = QProcess.startDetached(args[0], args[1:], wd) + started, pid = QProcess.startDetached( + args[0], args[1:], wd) if not started: - E5MessageBox.critical(None, + E5MessageBox.critical( + None, self.trUtf8('Process Generation Error'), - self.trUtf8('The Django process could not be started.')) + self.trUtf8('The Django process could not be' + ' started.')) except DjangoNoSiteSelectedException: pass @@ -2099,9 +2203,11 @@ wd = self.__sitePath() started, pid = QProcess.startDetached(args[0], args[1:], wd) if not started: - E5MessageBox.critical(None, + E5MessageBox.critical( + None, self.trUtf8('Process Generation Error'), - self.trUtf8('The Django process could not be started.')) + self.trUtf8('The Django process could not be' + ' started.')) except DjangoNoSiteSelectedException: pass @@ -2125,7 +2231,8 @@ args.append("manage.py") args.append("clearsessions") - dia = DjangoDialog(title, + dia = DjangoDialog( + title, msgSuccess=self.trUtf8("Expired sessions cleared successfully.")) res = dia.startProcess(args, wd) if res: @@ -2193,7 +2300,8 @@ @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) args = [] args.append(self.__getPythonExecutable()) @@ -2205,14 +2313,17 @@ try: wd = self.__sitePath() except DjangoNoSiteSelectedException: - E5MessageBox.warning(None, + E5MessageBox.warning( + None, title, self.trUtf8('No current site selected or no site created yet.' ' Aborting...')) return - dia = DjangoDialog(title, - msgSuccess=self.trUtf8("\nMessage catalog initialized successfully.")) + dia = DjangoDialog( + title, + msgSuccess=self.trUtf8( + "\nMessage catalog initialized successfully.")) res = dia.startProcess(args, wd) if res: dia.exec_() @@ -2232,7 +2343,8 @@ try: wd = self.__sitePath() except DjangoNoSiteSelectedException: - E5MessageBox.warning(None, + E5MessageBox.warning( + None, title, self.trUtf8('No current site selected or no site created yet.' ' Aborting...')) @@ -2240,7 +2352,8 @@ argsLists = [] - for filename in self.__normalizeList(self.__siteFilteredList(filenames)): + for filename in self.__normalizeList( + self.__siteFilteredList(filenames)): locale = self.__getLocale(filename) if locale: args = [] @@ -2253,12 +2366,14 @@ argsLists.append(args) if len(argsLists) == 0: - E5MessageBox.warning(None, + E5MessageBox.warning( + None, title, self.trUtf8('No locales detected. Aborting...')) return - dia = DjangoDialog(title, + dia = DjangoDialog( + title, msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) res = dia.startBatchProcesses(argsLists, wd) if res: @@ -2270,12 +2385,14 @@ @param filenames list of filenames """ - title = self.trUtf8("Updating message catalogs (keeping obsolete messages)") + title = self.trUtf8("Updating message catalogs (keeping obsolete" + " messages)") try: wd = self.__sitePath() except DjangoNoSiteSelectedException: - E5MessageBox.warning(None, + E5MessageBox.warning( + None, title, self.trUtf8('No current site selected or no site created yet.' ' Aborting...')) @@ -2283,7 +2400,8 @@ argsLists = [] - for filename in self.__normalizeList(self.__siteFilteredList(filenames)): + for filename in self.__normalizeList( + self.__siteFilteredList(filenames)): locale = self.__getLocale(filename) if locale: args = [] @@ -2295,12 +2413,14 @@ argsLists.append(args) if len(argsLists) == 0: - E5MessageBox.warning(None, + E5MessageBox.warning( + None, title, self.trUtf8('No locales detected. Aborting...')) return - dia = DjangoDialog(title, + dia = DjangoDialog( + title, msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) res = dia.startBatchProcesses(argsLists, wd) if res: @@ -2324,13 +2444,15 @@ try: wd = self.__sitePath() except DjangoNoSiteSelectedException: - E5MessageBox.warning(None, + E5MessageBox.warning( + None, title, self.trUtf8('No current site selected or no site created yet.' ' Aborting...')) return - dia = DjangoDialog(title, + dia = DjangoDialog( + title, msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) res = dia.startProcess(args, wd) if res: @@ -2342,7 +2464,8 @@ @param filenames list of filenames (not used) """ - title = self.trUtf8("Updating message catalogs (keeping obsolete messages)") + title = self.trUtf8("Updating message catalogs (keeping obsolete" + " messages)") args = [] args.append(self.__getPythonExecutable()) @@ -2353,13 +2476,15 @@ try: wd = self.__sitePath() except DjangoNoSiteSelectedException: - E5MessageBox.warning(None, + E5MessageBox.warning( + None, title, self.trUtf8('No current site selected or no site created yet.' ' Aborting...')) return - dia = DjangoDialog(title, + dia = DjangoDialog( + title, msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) res = dia.startProcess(args, wd) if res: @@ -2376,7 +2501,8 @@ try: wd = self.__sitePath() except DjangoNoSiteSelectedException: - E5MessageBox.warning(None, + E5MessageBox.warning( + None, title, self.trUtf8('No current site selected or no site created yet.' ' Aborting...')) @@ -2384,7 +2510,8 @@ argsLists = [] - for filename in self.__normalizeList(self.__siteFilteredList(filenames)): + for filename in self.__normalizeList( + self.__siteFilteredList(filenames)): locale = self.__getLocale(filename) if locale: args = [] @@ -2396,13 +2523,16 @@ argsLists.append(args) if len(argsLists) == 0: - E5MessageBox.warning(None, + E5MessageBox.warning( + None, title, self.trUtf8('No locales detected. Aborting...')) return - dia = DjangoDialog(title, - msgSuccess=self.trUtf8("\nMessage catalogs compiled successfully.")) + dia = DjangoDialog( + title, + msgSuccess=self.trUtf8( + "\nMessage catalogs compiled successfully.")) res = dia.startBatchProcesses(argsLists, wd, mergedOutput=True) if res: dia.exec_() @@ -2429,14 +2559,17 @@ try: wd = self.__sitePath() except DjangoNoSiteSelectedException: - E5MessageBox.warning(None, + E5MessageBox.warning( + None, title, self.trUtf8('No current site selected or no site created yet.' ' Aborting...')) return - dia = DjangoDialog(title, - msgSuccess=self.trUtf8("\nMessage catalogs compiled successfully.")) + dia = DjangoDialog( + title, + msgSuccess=self.trUtf8( + "\nMessage catalogs compiled successfully.")) res = dia.startProcess(args, wd, mergedOutput=True) if res: dia.exec_() @@ -2461,7 +2594,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)))