ProjectPyramid/Project.py

Sun, 27 Oct 2013 22:43:17 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Sun, 27 Oct 2013 22:43:17 +0100
changeset 56
c7adc68350dd
parent 48
c313efdb01de
child 57
e654970c913e
permissions
-rw-r--r--

Python 2 compatibility for Eric 5.

2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
34
d20f7218d53c Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
3 # Copyright (c) 2012 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the Pyramid project support.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
10 from __future__ import unicode_literals # __IGNORE_WARNING__
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
11
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
12 try:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
13 import configparser
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
14 except ImportError:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
15 str = unicode # __IGNORE_WARNING__
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
16 import ConfigParser as configparser # __IGNORE_WARNING__
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
17
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 import os
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
19 import re
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
20 import sys
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
22 from PyQt4.QtCore import QObject, QFileInfo, QTimer, QUrl
8
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
23 from PyQt4.QtGui import QMenu, QDialog, QInputDialog, QDesktopServices, QLineEdit
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
24 from PyQt4.QtCore import QProcess as QProcessPyQt
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 from E5Gui.E5Application import e5App
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 from E5Gui import E5MessageBox, E5FileDialog
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 from E5Gui.E5Action import E5Action
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 from .PyramidDialog import PyramidDialog
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
32 import Preferences
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 import Utilities
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 from Globals import isWindowsPlatform
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 import UI.PixmapCache
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 class PyramidNoProjectSelectedException(Exception):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 Exception thrown to signal, that there is no current Pyramid project.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 pass
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
45 class QProcess(QProcessPyQt):
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
46 """
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
47 Class transforming the call arguments in case of gnome-terminal.
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
48 """
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
49 def start(self, cmd, args=[], mode=QProcessPyQt.ReadWrite):
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
50 """
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
51 Starts the given program (cmd) in a new process, if none is already
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
52 running, passing the command line arguments in argss.
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
53
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
54 @param cmd start the given program cmd (string)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
55 @keyparam args list of parameters (list of strings)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
56 @keyparam mode access mode (QIODevice.OpenMode)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
57 """
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
58 if cmd.endswith('gnome-terminal') and args[0] == '-e':
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
59 args = ['-e', ' '.join(args[1:])]
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
60
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
61 super(QProcess, self).start(cmd, args, mode)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
62
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
63 @staticmethod
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
64 def startDetached(cmd, args=[], path=''):
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
65 """
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
66 Starts the given program (cmd) in a new process, if none is already
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
67 running, passing the command line arguments in argss.
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
68
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
69 @param cmd start the given program cmd (string)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
70 @keyparam args list of parameters (list of strings)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
71 @keyparam path new working directory (string)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
72 @return tuple of successful start and process id (boolean, integer)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
73 """
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
74 if cmd.endswith('gnome-terminal') and args[0] == '-e':
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
75 args = ['-e', ' '.join(args[1:])]
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
76
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
77 return QProcessPyQt.startDetached(cmd, args, path)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
78
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
79
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 class Project(QObject):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 Class implementing the Pyramid project support.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 """
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
84 def __init__(self, plugin, parent=None):
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 Constructor
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 @param plugin reference to the plugin object
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 @param parent parent (QObject)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 """
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
91 super(Project, self).__init__(parent)
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.__plugin = plugin
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 self.__ui = parent
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.__e5project = e5App().getObject("Project")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 self.__hooksInstalled = False
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.__mainMenu = None
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 self.__serverProc = None
44
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
101
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
102 self.__pyramidVersion = ""
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 def initActions(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 Public method to define the Pyramid actions.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 self.actions = []
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.selectProjectAct = E5Action(self.trUtf8('Current Pyramid Project'),
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 "",
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 0, 0,
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
113 self, 'pyramid_current_project')
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 self.selectProjectAct.setStatusTip(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 'Selects the current Pyramid project'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.selectProjectAct.setWhatsThis(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 """<b>Current Pyramid Project</b>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 """<p>Selects the Pyramid project. Used for multi-project """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 """Pyramid projects to switch between the projects.</p>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 ))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 self.selectProjectAct.triggered[()].connect(self.__selectProject)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 self.actions.append(self.selectProjectAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 ###############################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 ## create actions below ##
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 ###############################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 self.createProjectAct = E5Action(self.trUtf8('Create Pyramid Project'),
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
129 self.trUtf8('Create Pyramid &Project'),
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 0, 0,
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
131 self, 'pyramid_create_project')
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 self.createProjectAct.setStatusTip(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 'Creates a new Pyramid project'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 self.createProjectAct.setWhatsThis(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 """<b>Create Pyramid Project</b>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 """<p>Creates a new Pyramid project using "pcreate".</p>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 ))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 self.createProjectAct.triggered[()].connect(self.__createProject)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 self.actions.append(self.createProjectAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 ##############################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 ## run actions below ##
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 ##############################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 self.runServerAct = E5Action(self.trUtf8('Run Server'),
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
146 self.trUtf8('Run &Server'),
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 0, 0,
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
148 self, 'pyramid_run_server')
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.runServerAct.setStatusTip(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 'Starts the Pyramid Web server'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 self.runServerAct.setWhatsThis(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 """<b>Run Server</b>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 """<p>Starts the Pyramid Web server using"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 """ "pserve --reload development.ini".</p>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 ))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 self.runServerAct.triggered[()].connect(self.__runServer)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 self.actions.append(self.runServerAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 self.runLoggingServerAct = E5Action(self.trUtf8('Run Server with Logging'),
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
160 self.trUtf8('Run Server with &Logging'),
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 0, 0,
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
162 self, 'pyramid_run_logging_server')
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 self.runLoggingServerAct.setStatusTip(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 'Starts the Pyramid Web server with logging'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 self.runLoggingServerAct.setWhatsThis(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 """<b>Run Server with Logging</b>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 """<p>Starts the Pyramid Web server with logging using"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 """ "pserve --log-file=server.log --reload development.ini".</p>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 ))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 self.runLoggingServerAct.triggered[()].connect(self.__runLoggingServer)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 self.actions.append(self.runLoggingServerAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 self.runBrowserAct = E5Action(self.trUtf8('Run Web-Browser'),
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
174 self.trUtf8('Run &Web-Browser'),
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 0, 0,
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
176 self, 'pyramid_run_browser')
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 self.runBrowserAct.setStatusTip(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 'Starts the default Web-Browser with the URL of the Pyramid Web server'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 self.runBrowserAct.setWhatsThis(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 """<b>Run Web-Browser</b>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 """<p>Starts the default Web-Browser with the URL of the """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 """Pyramid Web server.</p>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 ))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 self.runBrowserAct.triggered[()].connect(self.__runBrowser)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 self.actions.append(self.runBrowserAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 self.runPythonShellAct = E5Action(self.trUtf8('Start Pyramid Python Console'),
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
188 self.trUtf8('Start Pyramid &Python Console'),
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 0, 0,
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
190 self, 'pyramid_python_console')
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 self.runPythonShellAct.setStatusTip(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 'Starts an interactive Python interpreter'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 self.runPythonShellAct.setWhatsThis(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 """<b>Start Pyramid Python Console</b>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 """<p>Starts an interactive Python interpreter.</p>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 ))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 self.runPythonShellAct.triggered[()].connect(self.__runPythonShell)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 self.actions.append(self.runPythonShellAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 ##############################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 ## setup actions below ##
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 ##############################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 self.setupDevelopAct = E5Action(self.trUtf8('Setup Development Environment'),
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
205 self.trUtf8('Setup &Development Environment'),
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 0, 0,
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
207 self, 'pyramid_setup_development')
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 self.setupDevelopAct.setStatusTip(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 'Setup the Pyramid project in development mode'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 self.setupDevelopAct.setWhatsThis(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 """<b>Setup Development Environment</b>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 """<p>Setup the Pyramid project in development mode using"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 """ "python setup.py develop".</p>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 ))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 self.setupDevelopAct.triggered[()].connect(self.__setupDevelop)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 self.actions.append(self.setupDevelopAct)
5
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
217
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
218 ###############################
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
219 ## database actions below ##
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
220 ###############################
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
221
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
222 self.initializeDbAct = E5Action(self.trUtf8('Initialize Database'),
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
223 self.trUtf8('Initialize &Database'),
5
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
224 0, 0,
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
225 self, 'pyramid_initialize_database')
5
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
226 self.initializeDbAct.setStatusTip(self.trUtf8(
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
227 'Initializes (or re-initializes) the database of the current'
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
228 ' Pyramid project'))
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
229 self.initializeDbAct.setWhatsThis(self.trUtf8(
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
230 """<b>Initialize Database</b>"""
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
231 """<p>Initializes (or re-initializes) the database of the current"""
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
232 """ Pyramid project.</p>"""
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
233 ))
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
234 self.initializeDbAct.triggered[()].connect(self.__initializeDatabase)
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
235 self.actions.append(self.initializeDbAct)
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
236
8
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
237 ###############################
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
238 ## show actions below ##
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
239 ###############################
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
240
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
241 self.showViewsAct = E5Action(self.trUtf8('Show Matching Views'),
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
242 self.trUtf8('Show Matching &Views'),
8
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
243 0, 0,
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
244 self, 'pyramid_show_views')
8
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
245 self.showViewsAct.setStatusTip(self.trUtf8(
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
246 'Show views matching a given URL'))
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
247 self.showViewsAct.setWhatsThis(self.trUtf8(
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
248 """<b>Show Matching Views</b>"""
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
249 """<p>Show views matching a given URL.</p>"""
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
250 ))
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
251 self.showViewsAct.triggered[()].connect(self.__showMatchingViews)
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
252 self.actions.append(self.showViewsAct)
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
253
13
227a115ab2a1 Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
254 self.showRoutesAct = E5Action(self.trUtf8('Show Routes'),
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
255 self.trUtf8('Show &Routes'),
9
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
256 0, 0,
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
257 self, 'pyramid_show_routes')
9
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
258 self.showRoutesAct.setStatusTip(self.trUtf8(
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
259 'Show all URL dispatch routes used by a Pyramid application'))
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
260 self.showRoutesAct.setWhatsThis(self.trUtf8(
13
227a115ab2a1 Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
261 """<b>Show Routes</b>"""
9
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
262 """<p>Show all URL dispatch routes used by a Pyramid application"""
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
263 """ in the order in which they are evaluated.</p>"""
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
264 ))
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
265 self.showRoutesAct.triggered[()].connect(self.__showRoutes)
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
266 self.actions.append(self.showRoutesAct)
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
267
13
227a115ab2a1 Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
268 self.showTweensAct = E5Action(self.trUtf8('Show Tween Objects'),
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
269 self.trUtf8('Show &Tween Objects'),
10
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
270 0, 0,
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
271 self, 'pyramid_show_routes')
10
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
272 self.showTweensAct.setStatusTip(self.trUtf8(
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
273 'Show all implicit and explicit tween objects used by a Pyramid application'))
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
274 self.showTweensAct.setWhatsThis(self.trUtf8(
13
227a115ab2a1 Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
275 """<b>Show Tween Objects</b>"""
10
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
276 """<p>Show all implicit and explicit tween objects used by a"""
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
277 """ Pyramid application.</p>"""
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
278 ))
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
279 self.showTweensAct.triggered[()].connect(self.__showTweens)
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
280 self.actions.append(self.showTweensAct)
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
281
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 ##################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 ## distribution actions below ##
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 ##################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 self.buildDistroAct = E5Action(self.trUtf8('Build Distribution'),
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
287 self.trUtf8('Build &Distribution'),
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 0, 0,
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
289 self, 'pyramid_build_distribution')
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 self.buildDistroAct.setStatusTip(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 'Builds a distribution file for the Pyramid project'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 self.buildDistroAct.setWhatsThis(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 """<b>Build Distribution</b>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 """<p>Builds a distribution file for the Pyramid project using"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 """ "python setup.py sdist".</p>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 ))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 self.buildDistroAct.triggered[()].connect(self.__buildDistribution)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 self.actions.append(self.buildDistroAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 ##################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 ## documentation action below ##
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 ##################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 self.documentationAct = E5Action(self.trUtf8('Documentation'),
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
305 self.trUtf8('D&ocumentation'),
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 0, 0,
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
307 self, 'pyramid_documentation')
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 self.documentationAct.setStatusTip(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 'Shows the help viewer with the Pyramid documentation'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 self.documentationAct.setWhatsThis(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 """<b>Documentation</b>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 """<p>Shows the help viewer with the Pyramid documentation.</p>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 ))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 self.documentationAct.triggered[()].connect(self.__showDocumentation)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 self.actions.append(self.documentationAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 ##############################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 ## about action below ##
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 ##############################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 self.aboutPyramidAct = E5Action(self.trUtf8('About Pyramid'),
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
322 self.trUtf8('About P&yramid'),
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 0, 0,
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
324 self, 'pyramid_about')
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 self.aboutPyramidAct.setStatusTip(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 'Shows some information about Pyramid'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 self.aboutPyramidAct.setWhatsThis(self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 """<b>About Pyramid</b>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 """<p>Shows some information about Pyramid.</p>"""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 ))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 self.aboutPyramidAct.triggered[()].connect(self.__pyramidInfo)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 self.actions.append(self.aboutPyramidAct)
5
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
333
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
334 self.__setCurrentProject(None)
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 def initMenu(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 Public slot to initialize the Pyramid menu.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 @return the menu generated (QMenu)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 menu = QMenu(self.trUtf8('P&yramid'), self.__ui)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 menu.setTearOffEnabled(True)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 menu.addAction(self.selectProjectAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 menu.addSeparator()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 menu.addAction(self.runServerAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 menu.addAction(self.runLoggingServerAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 menu.addAction(self.runBrowserAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 menu.addSeparator()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 menu.addAction(self.createProjectAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 menu.addSeparator()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 menu.addAction(self.setupDevelopAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 menu.addSeparator()
5
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
355 menu.addAction(self.initializeDbAct)
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
356 menu.addSeparator()
8
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
357 menu.addAction(self.showViewsAct)
9
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
358 menu.addAction(self.showRoutesAct)
10
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
359 menu.addAction(self.showTweensAct)
8
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
360 menu.addSeparator()
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 menu.addAction(self.runPythonShellAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 menu.addSeparator()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 menu.addAction(self.buildDistroAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 menu.addSeparator()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 menu.addAction(self.documentationAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 menu.addSeparator()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 menu.addAction(self.aboutPyramidAct)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 self.__mainMenu = menu
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 return menu
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371
48
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
372 def registerOpenHook(self):
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
373 """
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
374 Public method to register the open hook to open a translations file
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
375 in a translations editor.
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
376 """
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
377 if self.__hooksInstalled:
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
378 editor = self.__plugin.getPreferences("TranslationsEditor")
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
379 try:
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
380 if editor:
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
381 self.__translationsBrowser.addHookMethodAndMenuEntry("open",
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
382 self.openPOEditor,
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
383 self.trUtf8("Open with {0}").format(os.path.basename(editor)))
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
384 else:
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
385 self.__translationsBrowser.removeHookMethod("open")
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
386 except KeyError:
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
387 # ignore for older eric5 versions
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
388 pass
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
389
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 def projectOpenedHooks(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 Public method to add our hook methods.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 if self.__e5project.getProjectType() == "Pyramid":
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 self.__formsBrowser = \
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 e5App().getObject("ProjectBrowser").getProjectBrowser("forms")
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
397 self.__formsBrowser.addHookMethodAndMenuEntry("newForm",
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 self.newForm, self.trUtf8("New template..."))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
400 if self.__e5project.getProjectLanguage() == "Python2":
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
401 # Babel and lingua are not yet available for Python 3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
402 self.__e5project.projectLanguageAddedByCode.connect(
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
403 self.__projectLanguageAdded)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
404 self.__translationsBrowser = \
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
405 e5App().getObject("ProjectBrowser").getProjectBrowser("translations")
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
406 self.__translationsBrowser.addHookMethodAndMenuEntry("extractMessages",
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
407 self.extractMessages, self.trUtf8("Extract Messages"))
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
408 self.__translationsBrowser.addHookMethodAndMenuEntry("releaseAll",
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
409 self.compileCatalogs, self.trUtf8("Compile All Catalogs"))
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
410 self.__translationsBrowser.addHookMethodAndMenuEntry("releaseSelected",
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
411 self.compileSelectedCatalogs,
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
412 self.trUtf8("Compile Selected Catalogs"))
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
413 self.__translationsBrowser.addHookMethodAndMenuEntry("generateAll",
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
414 self.updateCatalogs, self.trUtf8("Update All Catalogs"))
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
415 self.__translationsBrowser.addHookMethodAndMenuEntry("generateSelected",
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
416 self.updateSelectedCatalogs, self.trUtf8("Update Selected Catalogs"))
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
417
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
418 self.__hooksInstalled = True
48
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
419
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
420 self.registerOpenHook()
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 def projectClosedHooks(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 Public method to remove our hook methods.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 if self.__hooksInstalled:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 self.__formsBrowser.removeHookMethod("newForm")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 self.__formsBrowser = None
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
430 self.__e5project.projectLanguageAddedByCode.disconnect(
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
431 self.__projectLanguageAdded)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
432 self.__translationsBrowser.removeHookMethod("extractMessages")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
433 self.__translationsBrowser.removeHookMethod("releaseAll")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
434 self.__translationsBrowser.removeHookMethod("releaseSelected")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
435 self.__translationsBrowser.removeHookMethod("generateAll")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
436 self.__translationsBrowser.removeHookMethod("generateSelected")
48
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
437 try:
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
438 self.__translationsBrowser.removeHookMethod("open")
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
439 except KeyError:
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
440 # ignore for older eric5 versions
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
441 pass
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
442 self.__translationsBrowser = None
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
443
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
444 self.__hooksInstalled = False
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 def newForm(self, path):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 Public method to create a new form.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 @param path full directory path for the new form file (string)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 """
37
1b089e0fba1e Modified the code to do lazy import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
452 from .FormSelectionDialog import FormSelectionDialog
1b089e0fba1e Modified the code to do lazy import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
453
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 dlg = FormSelectionDialog()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 if dlg.exec_() == QDialog.Accepted:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 template = dlg.getTemplateText()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 filter = self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 "Chameleon Templates (*.pt);;"
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 "Chameleon Text Templates (*.txt);;"
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 "Mako Templates (*.mako);;"
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 "Mako Templates (*.mak);;"
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 "HTML Files (*.html);;"
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 "HTML Files (*.htm);;"
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 "All Files (*)")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 self.__ui,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 self.trUtf8("New Form"),
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 path,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 filter,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 None,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 if fname:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 ext = QFileInfo(fname).suffix()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 if not ext:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 ex = selectedFilter.split("(*")[1].split(")")[0]
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 if ex:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 fname += ex
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 if os.path.exists(fname):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 res = E5MessageBox.yesNo(self.__ui,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 self.trUtf8("New Form"),
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 self.trUtf8("""The file already exists! Overwrite it?"""),
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
484 icon=E5MessageBox.Warning)
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 if not res:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486 # user selected to not overwrite
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 return
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 try:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 f = open(fname, "w", encoding="utf-8")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 f.write(template)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492 f.close()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493 except IOError as e:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494 E5MessageBox.critical(self,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 self.trUtf8("New Form"),
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 self.trUtf8("<p>The new form file <b>{0}</b> could not be"
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 " created.<br/>"
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 "Problem: {1}</p>").format(fname, e))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 return
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 self.__e5project.appendFile(fname)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 self.__formsBrowser.sourceFile.emit(fname)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 ##################################################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 ## methods below implement general functionality
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 ##################################################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 def projectClosed(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 Public method to handle the closing of a project.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 if self.__serverProc is not None:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513 self.__serverProcFinished()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 self.__setCurrentProject(None)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515
44
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
516 def __getExecutablePaths(self, file):
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
517 """
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
518 Private method to build all full path of an executable file from
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
519 the environment.
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
520
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
521 @param file filename of the executable (string)
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
522 @return list of full executable names, if the executable file is accessible
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
523 via the searchpath defined by the PATH environment variable, or an
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
524 empty list otherwise.
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
525 """
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
526 paths = []
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
527
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
528 if os.path.isabs(file):
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
529 if os.access(file, os.X_OK):
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
530 return [file]
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
531 else:
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
532 return []
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
533
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
534 cur_path = os.path.join(os.curdir, file)
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
535 if os.path.exists(cur_path):
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
536 if os.access(cur_path, os.X_OK):
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
537 paths.append(cur_path)
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
538
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
539 path = os.getenv('PATH')
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
540
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
541 # environment variable not defined
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
542 if path is not None:
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
543 dirs = path.split(os.pathsep)
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
544 for dir in dirs:
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
545 exe = os.path.join(dir, file)
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
546 if os.access(exe, os.X_OK) and exe not in paths:
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
547 paths.append(exe)
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
548
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
549 return paths
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
550
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
551 def supportedPythonVariants(self):
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
552 """
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
553 Public method to get the supported Python variants.
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
554
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
555 @return list of supported Python variants (list of strings)
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
556 """
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
557 variants = []
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
558 cmd = "pcreate"
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
559
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
560 for variant in 'Python2', 'Python3':
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
561 virtEnv = self.__getVirtualEnvironment(variant)
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
562 if virtEnv:
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
563 fullCmd = self.getPyramidCommand(cmd, variant)
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
564 if fullCmd != cmd:
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
565 variants.append(variant)
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
566 else:
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
567 if isWindowsPlatform():
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
568 debugEnv = self.__getDebugEnvironment(variant)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
569 fullCmd = os.path.join(debugEnv, "Scripts", cmd)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
570 if variant.lower() in fullCmd.lower():
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
571 variants.append(variant)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
572 else:
44
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
573 try:
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
574 fullCmds = Utilities.getExecutablePaths(cmd)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
575 except AttributeError:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
576 fullCmds = self.__getExecutablePaths(cmd)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
577 for fullCmd in fullCmds:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
578 try:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
579 f = open(fullCmd, 'r', encoding='utf-8')
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
580 l0 = f.readline()
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
581 f.close()
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
582 except (IOError, OSError):
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
583 l0 = ""
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
584 if variant.lower() in l0.lower() or \
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
585 "{0}.".format(variant[-1]) in l0 or \
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
586 (variant == "Python2" and \
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
587 "python3" not in l0.lower() and \
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
588 "python" in l0.lower()):
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
589 variants.append(variant)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
590 break
44
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
591
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
592 return variants
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
593
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
594 def __getVirtualEnvironment(self, language=""):
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
595 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
596 Private method to get the path of the virtual environment.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
597
44
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
598 @param language Python variant to get the virtual environment
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
599 for (string, one of '', 'Python2' or 'Python3')
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
600 @return path of the virtual environment (string)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
601 """
44
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
602 if not language:
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
603 language = self.__e5project.getProjectLanguage()
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
604 if language == "Python3":
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
605 virtEnv = self.__plugin.getPreferences("VirtualEnvironmentPy3")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
606 elif language == "Python2":
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
607 virtEnv = self.__plugin.getPreferences("VirtualEnvironmentPy2")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
608 else:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
609 virtEnv = ""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
610 if virtEnv and not os.path.exists(virtEnv):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
611 virtEnv = ""
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612 return virtEnv
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
613
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
614 def __getDebugEnvironment(self, language=""):
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
615 """
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
616 Private method to get the path of the debugger environment.
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
617
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
618 @param language Python variant to get the debugger environment
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
619 for (string, one of '', 'Python2' or 'Python3')
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
620 @return path of the debugger environment (string)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
621 """
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
622 if not language:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
623 language = self.__e5project.getProjectLanguage()
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
624 if language == "Python3":
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
625 debugEnv = Preferences.getDebugger("Python3Interpreter")
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
626 elif language == "Python2":
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
627 debugEnv = Preferences.getDebugger("PythonInterpreter")
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
628 else:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
629 debugEnv = sys.executable
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
630 debugEnv = os.path.dirname(debugEnv)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
631 if debugEnv and not os.path.exists(debugEnv):
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
632 debugEnv = sys.exec_prefix
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
633 return debugEnv
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
634
44
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
635 def getPyramidCommand(self, cmd, language=""):
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 Public method to build a Pyramid command.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639 @param cmd command (string)
44
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
640 @param language Python variant to get the virtual environment
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
641 for (string, one of '', 'Python2' or 'Python3')
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
642 @return full pyramid command (string)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643 """
44
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
644 virtualEnv = self.__getVirtualEnvironment(language)
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
645 if isWindowsPlatform() and not virtualEnv:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
646 virtualEnv = self.__getDebugEnvironment(language)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
647 if isWindowsPlatform():
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
648 cmd = os.path.join(virtualEnv, "Scripts", cmd + '.exe')
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
649 else:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
650 fullCmds = [
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
651 os.path.join(virtualEnv, "bin", cmd),
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
652 os.path.join(virtualEnv, "local", "bin", cmd),
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
653 Utilities.getExecutablePath(cmd),
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
654 cmd # fall back to just cmd
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
655 ]
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
656 for cmd in fullCmds:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
657 if os.path.exists(cmd):
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
658 break
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659 return cmd
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
661 def getPythonCommand(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
662 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
663 Public method to build the Python command.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
664
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
665 @return python command (string)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
666 """
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
667 language = self.__e5project.getProjectLanguage()
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
668 pythonExe = "python"
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
669 if isWindowsPlatform():
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
670 pythonExe += ".exe"
39
94e448a362b2 Bug fixes for better Python2 and Python3 support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
671 else:
94e448a362b2 Bug fixes for better Python2 and Python3 support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
672 if language == "Python3":
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
673 pythonExe = "python3"
39
94e448a362b2 Bug fixes for better Python2 and Python3 support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
674 elif language == "Python2":
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
675 pythonExe = "python2"
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
676 virtualEnv = self.__getVirtualEnvironment()
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
677 if isWindowsPlatform() and not virtualEnv:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
678 virtualEnv = self.__getDebugEnvironment(language)
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
679 if virtualEnv:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
680 if isWindowsPlatform():
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
681 python = os.path.join(virtualEnv, "Scripts", pythonExe)
39
94e448a362b2 Bug fixes for better Python2 and Python3 support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
682 if not os.path.exists(python):
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
683 python = os.path.join(virtualEnv, pythonExe)
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
684 else:
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
685 python = os.path.join(virtualEnv, "bin", pythonExe)
39
94e448a362b2 Bug fixes for better Python2 and Python3 support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
686 if not os.path.exists(python):
94e448a362b2 Bug fixes for better Python2 and Python3 support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
687 python = python[:-1] # omit the version character
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
688 else:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
689 python = pythonExe
39
94e448a362b2 Bug fixes for better Python2 and Python3 support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
690
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
691 return python
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
692
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
693 def __pyramidInfo(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
694 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
695 Private slot to show some info about Pyramid.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
696 """
44
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
697 version = self.getPyramidVersion()
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
698 url = "http://www.pylonsproject.org/projects/pyramid/about"
44
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
699
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
700 msgBox = E5MessageBox.E5MessageBox(E5MessageBox.Question,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
701 self.trUtf8("About Pyramid"),
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
702 self.trUtf8(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
703 "<p>Pyramid is a high-level Python Web framework that encourages rapid "
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
704 "development and clean, pragmatic design.</p>"
44
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
705 "<p><table>"
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
706 "<tr><td>Version:</td><td>{0}</td></tr>"
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
707 "<tr><td>URL:</td><td><a href=\"{1}\">"
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
708 "{1}</a></td></tr>"
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
709 "</table></p>"
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
710 ).format(version, url),
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
711 modal=True,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
712 buttons=E5MessageBox.Ok)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
713 msgBox.setIconPixmap(UI.PixmapCache.getPixmap(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714 os.path.join("ProjectPyramid", "icons", "pyramid64.png")))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715 msgBox.exec_()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
716
44
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
717 def getPyramidVersion(self):
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
718 """
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
719 Public method to get the Pyramid version.
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
720
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
721 @return Pyramid version (string)
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
722 """
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
723 if not self.__pyramidVersion:
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
724 cmd = self.getPyramidCommand("pcreate")
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
725 if isWindowsPlatform():
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
726 cmd = os.path.join(os.path.dirname(cmd), "pcreate-script.py")
44
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
727 try:
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
728 f = open(cmd, 'r', encoding="utf-8")
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
729 lines = f.read().splitlines()
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
730 f.close()
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
731 for line in lines:
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
732 if line.startswith("__requires__"):
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
733 # sample: __requires__ = 'pyramid==1.4'
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
734 vers = line.strip().split()[-1][1:-1].split("==")[1]
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
735 self.__pyramidVersion = vers
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
736 except (IOError, OSError):
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
737 self.__pyramidVersion = ""
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
738
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
739 return self.__pyramidVersion
989c961c33ab Extended the Python variant detection to only offer the Pyramid project type, if it is found for the respective Python.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 39
diff changeset
740
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
741 def isSpawningConsole(self, consoleCmd):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
742 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
743 Public method to check, if the given console is a spawning console.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
744
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
745 @param consoleCmd console command (string)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
746 @return tuple of two entries giving an indication, if the console
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747 is spawning (boolean) and the (possibly) cleaned console command
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
748 (string)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
749 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750 if consoleCmd and consoleCmd[0] == '@':
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751 return (True, consoleCmd[1:])
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752 else:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
753 return (False, consoleCmd)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
754
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
755 ##################################################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
756 ## slots below implement creation functions
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
757 ##################################################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
758
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
759 def __createProject(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
760 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
761 Private slot to create a new Pyramid project.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
762 """
37
1b089e0fba1e Modified the code to do lazy import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
763 from .CreateParametersDialog import CreateParametersDialog
1b089e0fba1e Modified the code to do lazy import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
764
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
765 dlg = CreateParametersDialog(self)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
766 if dlg.exec_() == QDialog.Accepted:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
767 scaffold, project, overwrite, simulate = dlg.getData()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
769 cmd = self.getPyramidCommand("pcreate")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
770 args = []
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
771 if overwrite:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
772 args.append("--overwrite")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
773 else:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
774 args.append("--interactive")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775 if simulate:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776 args.append("--simulate")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
777 args.append("--scaffold={0}".format(scaffold))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
778 args.append(project)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
779 dlg = PyramidDialog(self.trUtf8("Create Pyramid Project"),
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
780 linewrap=False, parent=self.__ui)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
781 if dlg.startProcess(cmd, args, self.__e5project.getProjectPath()):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
782 dlg.exec_()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
783 if dlg.normalExit() and not simulate:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
784 # search for files created by pcreate and add them to the project
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
785 projectPath = os.path.join(self.__e5project.getProjectPath(), project)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
786 for entry in os.walk(projectPath):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787 for fileName in entry[2]:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
788 fullName = os.path.join(entry[0], fileName)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
789 self.__e5project.appendFile(fullName)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
790
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
791 # create the base directory for translations
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
792 i18nPath = os.path.join(projectPath, project.lower(), "i18n")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
793 if not os.path.exists(i18nPath):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
794 os.makedirs(i18nPath)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
795 self.__e5project.setDirty(True)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
796
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
797 self.__setCurrentProject(project)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
798
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
799 ##################################################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
800 ## methods below implement site related functions
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801 ##################################################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803 def __findProjects(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804 """
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
805 Private method to determine the relative path of all Pyramid
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
806 projects (= top level dirs).
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
807
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
808 @return list of projects (list of string)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 projects = []
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
811 ppath = self.__e5project.getProjectPath()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
812 for entry in os.listdir(ppath):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
813 if entry[0] not in "._" and \
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
814 os.path.isdir(os.path.join(ppath, entry)):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
815 projects.append(entry)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
816 return projects
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
817
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
818 def __selectProject(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
819 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
820 Private method to select a Pyramid project to work with.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
821
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
822 @return selected project (string)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
823 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
824 projects = self.__findProjects()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
825 if len(projects) == 0:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
826 project = None
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
827 elif len(projects) == 1:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
828 project = projects[0]
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
829 else:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
830 if self.__currentProject is not None:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831 try:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 cur = projects.index(self.__currentProject)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
833 except ValueError:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
834 cur = 0
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
835 else:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
836 cur = 0
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
837 project, ok = QInputDialog.getItem(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
838 self.__ui,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
839 self.trUtf8("Select Pyramid Project"),
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
840 self.trUtf8("Select the Pyramid project to work with."),
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
841 projects,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
842 cur, False)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
843 if not ok:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
844 projects = None
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
845 self.__setCurrentProject(project)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
846
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
847 def __projectPath(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
848 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
849 Private method to calculate the full path of the Pyramid project.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
850
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
851 @exception PyramidNoProjectSelectedException raised, if no project is selected
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
852 @return path of the project (string)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854 if self.__currentProject is None:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 self.__selectProject()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
857 if self.__currentProject is None:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 raise PyramidNoProjectSelectedException
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
859 else:
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
860 return os.path.join(self.__e5project.getProjectPath(),
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861 self.__currentProject)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
862
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
863 def __setCurrentProject(self, project):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
864 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
865 Private slot to set the current project.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
866
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
867 @param project name of the project (string)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
868 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
869 if project is not None and len(project) == 0:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
870 self.__currentProject = None
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
871 else:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
872 self.__currentProject = project
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
873
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
874 if self.__currentProject is None:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
875 curProject = self.trUtf8("None")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
876 else:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
877 curProject = self.__currentProject
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
878 self.selectProjectAct.setText(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
879 self.trUtf8('&Current Pyramid Project ({0})').format(curProject))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
880
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
881 if self.__currentProject is None:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
882 self.__e5project.pdata["TRANSLATIONPATTERN"] = []
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
883 else:
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
884 lowerProject = self.__project().lower()
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
885 config = configparser.ConfigParser()
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
886 config.read(os.path.join(self.__projectPath(), "setup.cfg"))
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
887 try:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
888 outputDir = config.get("init_catalog", "output_dir")
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
889 except (configparser.NoOptionError, configparser.NoSectionError):
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
890 outputDir = '{0}/locale'.format(lowerProject)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
891 try:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
892 domain = config.get("init_catalog", "domain")
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
893 except (configparser.NoOptionError, configparser.NoSectionError):
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
894 domain = lowerProject
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
895 self.__e5project.pdata["TRANSLATIONPATTERN"] = [
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
896 os.path.join(project, outputDir, "%language%",
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
897 "LC_MESSAGES", "{0}.po".format(domain))
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
898 ]
5
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
899
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
900 if self.__currentProject is None:
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
901 self.initializeDbAct.setEnabled(False)
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
902 else:
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
903 initCmd = self.__getInitDbCommand()
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
904 self.initializeDbAct.setEnabled(os.path.exists(initCmd))
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
905
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
906 def __project(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
907 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
908 Private method to get the name of the current Pyramid project.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
909
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
910 @exception PyramidNoProjectSelectedException raised, if no project is selected
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
911 @return name of the project (string)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
912 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
913 if self.__currentProject is None:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
914 self.__selectProject()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
915
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
916 if self.__currentProject is None:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
917 raise PyramidNoProjectSelectedException
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
918 else:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
919 return self.__currentProject
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
920
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
921 ##################################################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
922 ## slots below implement run functions
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
923 ##################################################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
924
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
925 def __runServer(self, logging=False):
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
926 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
927 Private slot to start the Pyramid Web server.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
928
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
929 @param logging flag indicating to enable logging (boolean)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
930 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
931 consoleCmd = self.isSpawningConsole(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
932 self.__plugin.getPreferences("ConsoleCommand"))[1]
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
933 if consoleCmd:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
934 try:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
935 projectPath = self.__projectPath()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
936 except PyramidNoProjectSelectedException:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
937 E5MessageBox.warning(self.__ui,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
938 self.trUtf8('Run Server'),
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
939 self.trUtf8('No current Pyramid project selected or no Pyramid '
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
940 'project created yet. Aborting...'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
941 return
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
942
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
943 args = Utilities.parseOptionString(consoleCmd)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
944 args[0] = Utilities.getExecutablePath(args[0])
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
945 args.append(self.getPyramidCommand("pserve"))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
946 if logging:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
947 args.append("--log-file=server.log")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
948 args.append("--reload")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
949 args.append(os.path.join(projectPath, "development.ini"))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
950
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
951 if isWindowsPlatform():
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
952 serverProcStarted, pid = \
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
953 QProcess.startDetached(args[0], args[1:], projectPath)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
954 else:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
955 if self.__serverProc is not None:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
956 self.__serverProcFinished()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
957
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
958 self.__serverProc = QProcess()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
959 self.__serverProc.finished.connect(self.__serverProcFinished)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
960 self.__serverProc.setWorkingDirectory(projectPath)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
961 self.__serverProc.start(args[0], args[1:])
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
962 serverProcStarted = self.__serverProc.waitForStarted()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
963 if not serverProcStarted:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
964 E5MessageBox.critical(self.__ui,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
965 self.trUtf8('Process Generation Error'),
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
966 self.trUtf8('The Pyramid server could not be started.'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
967
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
968 def __runLoggingServer(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
969 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
970 Private slot to start the Pyramid Web server with logging.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
971 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
972 self.__runServer(True)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
973
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
974 def __serverProcFinished(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
975 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
976 Private slot connected to the finished signal.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
977 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
978 if self.__serverProc is not None and \
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
979 self.__serverProc.state() != QProcess.NotRunning:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
980 self.__serverProc.terminate()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
981 QTimer.singleShot(2000, self.__serverProc.kill)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
982 self.__serverProc.waitForFinished(3000)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
983 self.__serverProc = None
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
984
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
985 def __runBrowser(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
986 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
987 Private slot to start the default web browser with the server URL.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
988 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
989 try:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
990 projectPath = self.__projectPath()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
991 except PyramidNoProjectSelectedException:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
992 E5MessageBox.warning(self.__ui,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
993 self.trUtf8('Run Web-Browser'),
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
994 self.trUtf8('No current Pyramid project selected or no Pyramid project'
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
995 ' created yet. Aborting...'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
996 return
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
997
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
998 config = configparser.ConfigParser()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
999 config.read(os.path.join(projectPath, "development.ini"))
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1000 try:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1001 port = config.get("server:main", "port")
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1002 except (configparser.NoOptionError, configparser.NoSectionError):
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1003 port = "8080"
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1004 url = QUrl("http://localhost:{0}".format(port))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1005 res = QDesktopServices.openUrl(url)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1006 if not res:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1007 E5MessageBox.critical(self.__ui,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1008 self.trUtf8('Run Web-Browser'),
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1009 self.trUtf8('Could not start the web-browser for the URL "{0}".')\
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1010 .format(url.toString()))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1011
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1012 def __runPythonShell(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1013 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1014 Private slot to start a Python console for a Pyramid project.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1015 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1016 consoleCmd = self.isSpawningConsole(
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1017 self.__plugin.getPreferences("ConsoleCommand"))[1]
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1018 if consoleCmd:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1019 try:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1020 projectPath = self.__projectPath()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1021 except PyramidNoProjectSelectedException:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1022 E5MessageBox.warning(self.__ui,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1023 self.trUtf8('Start Pyramid Python Console'),
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1024 self.trUtf8('No current Pyramid project selected or no Pyramid '
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1025 'project created yet. Aborting...'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1026 return
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1027
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1028 args = Utilities.parseOptionString(consoleCmd)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1029 args[0] = Utilities.getExecutablePath(args[0])
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1030 args.append(self.getPyramidCommand("pshell"))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1031 language = self.__e5project.getProjectLanguage()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1032 if language == "Python2":
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1033 consoleType = self.__plugin.getPreferences("Python2ConsoleType")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1034 else:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1035 consoleType = self.__plugin.getPreferences("Python3ConsoleType")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1036 args.append("--python-shell={0}".format(consoleType))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1037 args.append(os.path.join(projectPath, "development.ini"))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1038
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1039 started, pid = QProcess.startDetached(args[0], args[1:], projectPath)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1040 if not started:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1041 E5MessageBox.critical(self.__ui,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1042 self.trUtf8('Process Generation Error'),
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1043 self.trUtf8('The Pyramid Shell process could not be started.'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1044
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1045 ##################################################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1046 ## slots below implement setup functions
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1047 ##################################################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1048
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1049 def __setupDevelop(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1050 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1051 Private slot to set up the development environment for the current project.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1052 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1053 title = self.trUtf8("Setup Development Environment")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1054 try:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1055 wd = self.__projectPath()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1056 except PyramidNoProjectSelectedException:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1057 E5MessageBox.warning(self.__ui,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1058 title,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1059 self.trUtf8('No current Pyramid project selected or no Pyramid project'
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1060 ' created yet. Aborting...'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1061 return
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1062
5
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1063 cmd = self.getPythonCommand()
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1064 args = []
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1065 args.append("setup.py")
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1066 args.append("develop")
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1067
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1068 dia = PyramidDialog(title,
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1069 msgSuccess=self.trUtf8("Pyramid development environment setup successfully."))
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1070 res = dia.startProcess(cmd, args, wd)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1071 if res:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1072 dia.exec_()
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1073 initCmd = self.__getInitDbCommand()
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1074 self.initializeDbAct.setEnabled(os.path.exists(initCmd))
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1075
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1076 ##################################################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1077 ## slots below implement distribution functions
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1078 ##################################################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1079
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1080 def __buildDistribution(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1081 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1082 Private slot to build a distribution file for the current Pyramid project.
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1083 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1084 title = self.trUtf8("Build Distribution File")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1085 try:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1086 projectPath = self.__projectPath()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1087 except PyramidNoProjectSelectedException:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1088 E5MessageBox.warning(self.__ui,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1089 title,
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1090 self.trUtf8('No current Pyramid project selected or no Pyramid project'
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1091 ' created yet. Aborting...'))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1092 return
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1093
37
1b089e0fba1e Modified the code to do lazy import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
1094 from .DistributionTypeSelectionDialog import DistributionTypeSelectionDialog
1b089e0fba1e Modified the code to do lazy import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
1095
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1096 dlg = DistributionTypeSelectionDialog(self, projectPath, self.__ui)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1097 if dlg.exec_() == QDialog.Accepted:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1098 formats = dlg.getFormats()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1099 cmd = self.getPythonCommand()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1100 args = []
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1101 args.append("setup.py")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1102 args.append("sdist")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1103 if formats:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1104 args.append("--formats={0}".format(','.join(formats)))
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1105
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1106 dia = PyramidDialog(title,
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1107 msgSuccess=self.trUtf8("Python distribution file built successfully."))
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1108 res = dia.startProcess(cmd, args, projectPath)
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1109 if res:
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1110 dia.exec_()
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1111
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1112 ##################################################################
5
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1113 ## slots below implement database functions
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1114 ##################################################################
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1115
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1116 def __getInitDbCommand(self):
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1117 """
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1118 Private method to create the path to the initialization script.
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1119
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1120 @return path to the initialization script (string)
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1121 """
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1122 try:
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1123 cmd = "initialize_{0}_db".format(self.__project())
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1124 return self.getPyramidCommand(cmd)
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1125 except PyramidNoProjectSelectedException:
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1126 E5MessageBox.warning(self.__ui,
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1127 self.trUtf8("Initialize Database"),
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1128 self.trUtf8('No current Pyramid project selected or no Pyramid project'
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1129 ' created yet. Aborting...'))
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1130 return ""
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1131
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1132 def __initializeDatabase(self):
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1133 """
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1134 Private slot to initialize the database of the Pyramid project.
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1135 """
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1136 title = self.trUtf8("Initialize Database")
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1137 try:
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1138 projectPath = self.__projectPath()
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1139 except PyramidNoProjectSelectedException:
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1140 E5MessageBox.warning(self.__ui,
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1141 title,
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1142 self.trUtf8('No current Pyramid project selected or no Pyramid project'
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1143 ' created yet. Aborting...'))
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1144 return
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1145
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1146 cmd = self.__getInitDbCommand()
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1147 args = []
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1148 args.append("development.ini")
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1149
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1150 dia = PyramidDialog(title,
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1151 msgSuccess=self.trUtf8("Database initialized successfully."))
5
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1152 res = dia.startProcess(cmd, args, projectPath)
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1153 if res:
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1154 dia.exec_()
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1155
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1156 ##################################################################
8
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1157 ## slots below implement various debugging functions
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1158 ##################################################################
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1159
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1160 def __showMatchingViews(self):
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1161 """
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1162 Private slot showing all views that would match a given URL.
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1163 """
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1164 title = self.trUtf8("Show Matching Views")
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1165 try:
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1166 projectPath = self.__projectPath()
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1167 except PyramidNoProjectSelectedException:
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1168 E5MessageBox.warning(self.__ui,
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1169 title,
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1170 self.trUtf8('No current Pyramid project selected or no Pyramid project'
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1171 ' created yet. Aborting...'))
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1172 return
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1173
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1174 url, ok = QInputDialog.getText(
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1175 self.__ui,
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1176 self.trUtf8("Show Matching Views"),
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1177 self.trUtf8("Enter the URL to be matched:"),
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1178 QLineEdit.Normal,
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1179 "/")
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1180 if not ok or url == "":
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1181 return
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1182
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1183 cmd = self.getPyramidCommand("pviews")
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1184 args = []
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1185 args.append("development.ini")
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1186 args.append(url)
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1187
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1188 dia = PyramidDialog(title, fixed=True, linewrap=False)
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1189 res = dia.startProcess(cmd, args, projectPath)
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1190 if res:
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1191 dia.exec_()
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1192
9
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1193 def __showRoutes(self):
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1194 """
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1195 Private slot showing all URL dispatch routes.
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1196 """
13
227a115ab2a1 Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
1197 title = self.trUtf8("Show Routes")
9
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1198 try:
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1199 projectPath = self.__projectPath()
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1200 except PyramidNoProjectSelectedException:
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1201 E5MessageBox.warning(self.__ui,
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1202 title,
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1203 self.trUtf8('No current Pyramid project selected or no Pyramid project'
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1204 ' created yet. Aborting...'))
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1205 return
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1206
37
1b089e0fba1e Modified the code to do lazy import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
1207 from .PyramidRoutesDialog import PyramidRoutesDialog
1b089e0fba1e Modified the code to do lazy import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
1208
13
227a115ab2a1 Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
1209 dia = PyramidRoutesDialog(self)
227a115ab2a1 Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
1210 res = dia.start(projectPath)
9
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1211 if res:
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1212 dia.exec_()
0ebc5b152c6c Added code for the 'proutes' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1213
10
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1214 def __showTweens(self):
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1215 """
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1216 Private slot showing all implicit and explicit tween objects.
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1217 """
13
227a115ab2a1 Added a specialized dialog to show the configured routes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
1218 title = self.trUtf8("Show Tween Objects")
10
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1219 try:
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1220 projectPath = self.__projectPath()
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1221 except PyramidNoProjectSelectedException:
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1222 E5MessageBox.warning(self.__ui,
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1223 title,
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1224 self.trUtf8('No current Pyramid project selected or no Pyramid project'
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1225 ' created yet. Aborting...'))
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1226 return
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1227
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1228 cmd = self.getPyramidCommand("ptweens")
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1229 args = []
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1230 args.append("development.ini")
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1231
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1232 dia = PyramidDialog(title, fixed=True, linewrap=False)
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1233 res = dia.startProcess(cmd, args, projectPath)
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1234 if res:
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1235 dia.exec_()
3330f7087434 Added code for the 'ptweens' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1236
8
ac62d7dc6a37 Added code for the 'pviews' command.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
1237 ##################################################################
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1238 ## slots below implement documentation functions
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1239 ##################################################################
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1240
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1241 def __showDocumentation(self):
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1242 """
5
455dc39cd212 Added action to initialize a Pyramid project database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1243 Private slot to show the helpviewer with the Pyramid documentation.
2
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1244 """
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1245 page = self.__plugin.getPreferences("PyramidDocUrl")
e691c51ab655 Implemented the required command actions for supporting development of Pyramid projects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1246 self.__ui.launchHelpViewer(page)
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1247
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1248 ##################################################################
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1249 ## slots below implement translation functions
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1250 ##################################################################
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1251
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1252 def __getLocale(self, filename):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1253 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1254 Private method to extract the locale out of a file name.
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1255
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1256 @param filename name of the file used for extraction (string)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1257 @return extracted locale (string) or None
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1258 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1259 if self.__e5project.pdata["TRANSLATIONPATTERN"]:
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1260 # On Windows, path typically contains backslashes. This leads
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1261 # to an invalid seach pattern '...\(' because the opening bracked
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1262 # will be escaped.
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1263 pattern = self.__e5project.pdata["TRANSLATIONPATTERN"][0]
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1264 pattern = os.path.normpath(pattern)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1265 pattern = pattern.replace("%language%", "(.*?)")
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1266 pattern = pattern.replace('\\', '\\\\')
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1267 match = re.search(pattern, filename)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1268 if match is not None:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1269 loc = match.group(1)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1270 return loc
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1271 else:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1272 loc = None
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1273 else:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1274 loc = None
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1275
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1276 return loc
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1277
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1278 def __normalizeList(self, filenames):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1279 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1280 Private method to normalize a list of file names.
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1281
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1282 @param filenames list of file names to normalize (list of string)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1283 @return normalized file names (list of string)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1284 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1285 nfilenames = []
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1286 for filename in filenames:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1287 if filename.endswith(".mo"):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1288 filename = filename.replace(".mo", ".po")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1289 if filename not in nfilenames:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1290 nfilenames.append(filename)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1291
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1292 return nfilenames
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1293
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1294 def __projectFilteredList(self, filenames):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1295 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1296 Private method to filter a list of file names by Pyramid project.
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1297
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1298 @param filenames list of file names to be filtered (list of string)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1299 @return file names belonging to the current site (list of string)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1300 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1301 project = self.__project()
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1302 nfilenames = []
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1303 for filename in filenames:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1304 if filename.startswith(project + os.sep):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1305 nfilenames.append(filename)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1306
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1307 return nfilenames
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1308
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1309 def extractMessages(self):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1310 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1311 Public method to extract the messages catalog template file.
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1312 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1313 title = self.trUtf8("Extract messages")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1314 try:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1315 projectPath = self.__projectPath()
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1316 except PyramidNoProjectSelectedException:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1317 E5MessageBox.warning(self.__ui,
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1318 title,
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1319 self.trUtf8('No current Pyramid project selected or no Pyramid project'
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1320 ' created yet. Aborting...'))
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1321 return
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1322
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1323 config = configparser.ConfigParser()
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1324 config.read(os.path.join(projectPath, "setup.cfg"))
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1325 try:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1326 potFile = config.get("extract_messages", "output_file")
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1327 except configparser.NoSectionError:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1328 E5MessageBox.warning(self.__ui,
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1329 title,
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1330 self.trUtf8('No setup.cfg found or no "extract_messages"'
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1331 ' section found in setup.cfg.'))
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1332 return
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1333 except configparser.NoOptionError:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1334 E5MessageBox.warning(self.__ui,
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1335 title,
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1336 self.trUtf8('No "output_file" option found in setup.cfg.'))
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1337 return
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1338
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1339 try:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1340 path = os.path.join(projectPath, os.path.dirname(potFile))
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1341 os.makedirs(path)
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1342 except OSError:
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1343 pass
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1344
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1345 cmd = self.getPythonCommand()
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1346 args = []
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1347 args.append("setup.py")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1348 args.append("extract_messages")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1349
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1350 dia = PyramidDialog(title,
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1351 msgSuccess=self.trUtf8("\nMessages extracted successfully."))
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1352 res = dia.startProcess(cmd, args, projectPath)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1353 if res:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1354 dia.exec_()
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1355 self.__e5project.appendFile(os.path.join(projectPath, potFile))
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1356
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1357 def __projectLanguageAdded(self, code):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1358 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1359 Private slot handling the addition of a new language.
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1360
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1361 @param code language code of the new language (string)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1362 """
14
e3cb581b4653 Added translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
1363 title = self.trUtf8("Initializing message catalog for '{0}'").format(code)
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1364 try:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1365 projectPath = self.__projectPath()
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1366 except PyramidNoProjectSelectedException:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1367 E5MessageBox.warning(self.__ui,
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1368 title,
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1369 self.trUtf8('No current Pyramid project selected or no Pyramid project'
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1370 ' created yet. Aborting...'))
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1371 return
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1372
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1373 cmd = self.getPythonCommand()
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1374 args = []
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1375 args.append("setup.py")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1376 args.append("init_catalog")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1377 args.append("-l")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1378 args.append(code)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1379
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1380 dia = PyramidDialog(title,
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1381 msgSuccess=self.trUtf8("\nMessage catalog initialized successfully."))
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1382 res = dia.startProcess(cmd, args, projectPath)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1383 if res:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1384 dia.exec_()
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1385
56
c7adc68350dd Python 2 compatibility for Eric 5.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 48
diff changeset
1386 langFile = self.__e5project.pdata["TRANSLATIONPATTERN"][0]\
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1387 .replace("%language%", code)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1388 self.__e5project.appendFile(langFile)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1389
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1390 def compileCatalogs(self, filenames):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1391 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1392 Public method to compile the message catalogs.
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1393
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1394 @param filenames list of filenames (not used)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1395 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1396 title = self.trUtf8("Compiling message catalogs")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1397 try:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1398 projectPath = self.__projectPath()
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1399 except PyramidNoProjectSelectedException:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1400 E5MessageBox.warning(self.__ui,
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1401 title,
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1402 self.trUtf8('No current Pyramid project selected or no Pyramid project'
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1403 ' created yet. Aborting...'))
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1404 return
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1405
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1406 cmd = self.getPythonCommand()
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1407 args = []
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1408 args.append("setup.py")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1409 args.append("compile_catalog")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1410
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1411 dia = PyramidDialog(title,
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1412 msgSuccess=self.trUtf8("\nMessage catalogs compiled successfully."))
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1413 res = dia.startProcess(cmd, args, projectPath)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1414 if res:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1415 dia.exec_()
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1416
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1417 for entry in os.walk(projectPath):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1418 for fileName in entry[2]:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1419 fullName = os.path.join(entry[0], fileName)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1420 if fullName.endswith('.mo'):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1421 self.__e5project.appendFile(fullName)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1422
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1423 def compileSelectedCatalogs(self, filenames):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1424 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1425 Public method to update the message catalogs.
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1426
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1427 @param filenames list of file names (list of string)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1428 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1429 title = self.trUtf8("Compiling message catalogs")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1430 try:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1431 projectPath = self.__projectPath()
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1432 except PyramidNoProjectSelectedException:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1433 E5MessageBox.warning(self.__ui,
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1434 title,
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1435 self.trUtf8('No current Pyramid project selected or no Pyramid project'
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1436 ' created yet. Aborting...'))
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1437 return
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1438
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1439 argsLists = []
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1440
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1441 for filename in self.__normalizeList(self.__projectFilteredList(filenames)):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1442 locale = self.__getLocale(filename)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1443 if locale:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1444 args = []
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1445 args.append(self.getPythonCommand())
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1446 args.append("setup.py")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1447 args.append("compile_catalog")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1448 args.append("-l")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1449 args.append(locale)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1450 argsLists.append(args)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1451
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1452 if len(argsLists) == 0:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1453 E5MessageBox.warning(self.__ui,
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1454 title,
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1455 self.trUtf8('No locales detected. Aborting...'))
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1456 return
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1457
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1458 dia = PyramidDialog(title,
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1459 msgSuccess=self.trUtf8("\nMessage catalogs compiled successfully."))
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1460 res = dia.startBatchProcesses(argsLists, projectPath)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1461 if res:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1462 dia.exec_()
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1463
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1464 for entry in os.walk(self.__sitePath()):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1465 for fileName in entry[2]:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1466 fullName = os.path.join(entry[0], fileName)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1467 if fullName.endswith('.mo'):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1468 self.__e5project.appendFile(fullName)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1469
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1470 def updateCatalogs(self, filenames):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1471 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1472 Public method to update the message catalogs.
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1473
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1474 @param filenames list of filenames (not used)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1475 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1476 title = self.trUtf8("Updating message catalogs")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1477 try:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1478 projectPath = self.__projectPath()
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1479 except PyramidNoProjectSelectedException:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1480 E5MessageBox.warning(self.__ui,
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1481 title,
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1482 self.trUtf8('No current Pyramid project selected or no Pyramid project'
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1483 ' created yet. Aborting...'))
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1484 return
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1485
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1486 cmd = self.getPythonCommand()
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1487 args = []
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1488 args.append("setup.py")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1489 args.append("update_catalog")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1490
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1491 dia = PyramidDialog(title,
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1492 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully."))
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1493 res = dia.startProcess(cmd, args, projectPath)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1494 if res:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1495 dia.exec_()
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1496
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1497 def updateSelectedCatalogs(self, filenames):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1498 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1499 Public method to update the message catalogs.
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1500
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1501 @param filenames list of filenames
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1502 """
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1503 title = self.trUtf8("Updating message catalogs")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1504 try:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1505 projectPath = self.__projectPath()
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1506 except PyramidNoProjectSelectedException:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1507 E5MessageBox.warning(self.__ui,
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1508 title,
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1509 self.trUtf8('No current Pyramid project selected or no Pyramid project'
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1510 ' created yet. Aborting...'))
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1511 return
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1512
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1513 argsLists = []
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1514
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1515 for filename in self.__normalizeList(self.__projectFilteredList(filenames)):
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1516 locale = self.__getLocale(filename)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1517 if locale:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1518 args = []
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1519 args.append(self.getPythonCommand())
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1520 args.append("setup.py")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1521 args.append("update_catalog")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1522 args.append("-l")
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1523 args.append(locale)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1524 argsLists.append(args)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1525
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1526 if len(argsLists) == 0:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1527 E5MessageBox.warning(self.__ui,
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1528 title,
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1529 self.trUtf8('No locales detected. Aborting...'))
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1530 return
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1531
19
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1532 dia = PyramidDialog(title,
f4adfe6e51b0 Corrected PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 14
diff changeset
1533 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully."))
3
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1534 res = dia.startBatchProcesses(argsLists, projectPath)
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1535 if res:
76c45d31d462 Added the internationalization related functions (only for Python 2 because babel and lingua are not supported by Python 3 yet).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1536 dia.exec_()
48
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1537
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1538 def openPOEditor(self, poFile):
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1539 """
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1540 Public method to edit the given file in an external .po editor.
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1541
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1542 @param poFile name of the .po file (string)
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1543 """
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1544 editor = self.__plugin.getPreferences("TranslationsEditor")
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1545 if poFile.endswith(".po") and editor:
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1546 try:
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1547 wd = self.__projectPath()
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1548 except PyramidNoProjectSelectedException:
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1549 wd = ""
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1550 started, pid = QProcess.startDetached(editor, [poFile], wd)
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1551 if not started:
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1552 E5MessageBox.critical(None,
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1553 self.trUtf8('Process Generation Error'),
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1554 self.trUtf8('The translations editor process ({0}) could not'
c313efdb01de Added a menu entry to call a translations editor from the translations viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
1555 ' be started.').format(os.path.basename(editor)))

eric ide

mercurial