72:3b3e73b730f0 | 74:11587ae1122f |
---|---|
17 | 17 |
18 import os | 18 import os |
19 import re | 19 import re |
20 import sys | 20 import sys |
21 | 21 |
22 from PyQt4.QtCore import QObject, QFileInfo, QTimer, QUrl | 22 from PyQt5.QtCore import QObject, QFileInfo, QTimer, QUrl |
23 from PyQt4.QtGui import QMenu, QDialog, QInputDialog, QDesktopServices, \ | 23 from PyQt5.QtGui import QDesktopServices |
24 QLineEdit | 24 from PyQt5.QtWidgets import QMenu, QDialog, QInputDialog, QLineEdit |
25 from PyQt4.QtCore import QProcess as QProcessPyQt | 25 from PyQt5.QtCore import QProcess as QProcessPyQt |
26 | 26 |
27 from E5Gui.E5Application import e5App | 27 from E5Gui.E5Application import e5App |
28 from E5Gui import E5MessageBox, E5FileDialog | 28 from E5Gui import E5MessageBox, E5FileDialog |
29 from E5Gui.E5Action import E5Action | 29 from E5Gui.E5Action import E5Action |
30 | 30 |
62 super(QProcess, self).start(cmd, args, mode) | 62 super(QProcess, self).start(cmd, args, mode) |
63 | 63 |
64 @staticmethod | 64 @staticmethod |
65 def startDetached(cmd, args=[], path=''): | 65 def startDetached(cmd, args=[], path=''): |
66 """ | 66 """ |
67 Static method to start the given program (cmd) in a new process, if | 67 Public static method to start the given program (cmd) in a new process, |
68 none is already running, passing the command line arguments in args. | 68 if none is already running, passing the command line arguments in args. |
69 | 69 |
70 @param cmd start the given program cmd (string) | 70 @param cmd start the given program cmd (string) |
71 @keyparam args list of parameters (list of strings) | 71 @keyparam args list of parameters (list of strings) |
72 @keyparam path new working directory (string) | 72 @keyparam path new working directory (string) |
73 @return tuple of successful start and process id (boolean, integer) | 73 @return tuple of successful start and process id (boolean, integer) |
107 Public method to define the Pyramid actions. | 107 Public method to define the Pyramid actions. |
108 """ | 108 """ |
109 self.actions = [] | 109 self.actions = [] |
110 | 110 |
111 self.selectProjectAct = E5Action( | 111 self.selectProjectAct = E5Action( |
112 self.trUtf8('Current Pyramid Project'), | 112 self.tr('Current Pyramid Project'), |
113 "", | 113 "", |
114 0, 0, | 114 0, 0, |
115 self, 'pyramid_current_project') | 115 self, 'pyramid_current_project') |
116 self.selectProjectAct.setStatusTip(self.trUtf8( | 116 self.selectProjectAct.setStatusTip(self.tr( |
117 'Selects the current Pyramid project')) | 117 'Selects the current Pyramid project')) |
118 self.selectProjectAct.setWhatsThis(self.trUtf8( | 118 self.selectProjectAct.setWhatsThis(self.tr( |
119 """<b>Current Pyramid Project</b>""" | 119 """<b>Current Pyramid Project</b>""" |
120 """<p>Selects the Pyramid project. Used for multi-project """ | 120 """<p>Selects the Pyramid project. Used for multi-project """ |
121 """Pyramid projects to switch between the projects.</p>""" | 121 """Pyramid projects to switch between the projects.</p>""" |
122 )) | 122 )) |
123 self.selectProjectAct.triggered[()].connect(self.__selectProject) | 123 self.selectProjectAct.triggered.connect(self.__selectProject) |
124 self.actions.append(self.selectProjectAct) | 124 self.actions.append(self.selectProjectAct) |
125 | 125 |
126 ############################### | 126 ############################### |
127 ## create actions below ## | 127 ## create actions below ## |
128 ############################### | 128 ############################### |
129 | 129 |
130 self.createProjectAct = E5Action( | 130 self.createProjectAct = E5Action( |
131 self.trUtf8('Create Pyramid Project'), | 131 self.tr('Create Pyramid Project'), |
132 self.trUtf8('Create Pyramid &Project'), | 132 self.tr('Create Pyramid &Project'), |
133 0, 0, | 133 0, 0, |
134 self, 'pyramid_create_project') | 134 self, 'pyramid_create_project') |
135 self.createProjectAct.setStatusTip(self.trUtf8( | 135 self.createProjectAct.setStatusTip(self.tr( |
136 'Creates a new Pyramid project')) | 136 'Creates a new Pyramid project')) |
137 self.createProjectAct.setWhatsThis(self.trUtf8( | 137 self.createProjectAct.setWhatsThis(self.tr( |
138 """<b>Create Pyramid Project</b>""" | 138 """<b>Create Pyramid Project</b>""" |
139 """<p>Creates a new Pyramid project using "pcreate".</p>""" | 139 """<p>Creates a new Pyramid project using "pcreate".</p>""" |
140 )) | 140 )) |
141 self.createProjectAct.triggered[()].connect(self.__createProject) | 141 self.createProjectAct.triggered.connect(self.__createProject) |
142 self.actions.append(self.createProjectAct) | 142 self.actions.append(self.createProjectAct) |
143 | 143 |
144 ############################## | 144 ############################## |
145 ## run actions below ## | 145 ## run actions below ## |
146 ############################## | 146 ############################## |
147 | 147 |
148 self.runServerAct = E5Action( | 148 self.runServerAct = E5Action( |
149 self.trUtf8('Run Server'), | 149 self.tr('Run Server'), |
150 self.trUtf8('Run &Server'), | 150 self.tr('Run &Server'), |
151 0, 0, | 151 0, 0, |
152 self, 'pyramid_run_server') | 152 self, 'pyramid_run_server') |
153 self.runServerAct.setStatusTip(self.trUtf8( | 153 self.runServerAct.setStatusTip(self.tr( |
154 'Starts the Pyramid Web server')) | 154 'Starts the Pyramid Web server')) |
155 self.runServerAct.setWhatsThis(self.trUtf8( | 155 self.runServerAct.setWhatsThis(self.tr( |
156 """<b>Run Server</b>""" | 156 """<b>Run Server</b>""" |
157 """<p>Starts the Pyramid Web server using""" | 157 """<p>Starts the Pyramid Web server using""" |
158 """ "pserve --reload development.ini".</p>""" | 158 """ "pserve --reload development.ini".</p>""" |
159 )) | 159 )) |
160 self.runServerAct.triggered[()].connect(self.__runServer) | 160 self.runServerAct.triggered.connect(self.__runServer) |
161 self.actions.append(self.runServerAct) | 161 self.actions.append(self.runServerAct) |
162 | 162 |
163 self.runLoggingServerAct = E5Action( | 163 self.runLoggingServerAct = E5Action( |
164 self.trUtf8('Run Server with Logging'), | 164 self.tr('Run Server with Logging'), |
165 self.trUtf8('Run Server with &Logging'), | 165 self.tr('Run Server with &Logging'), |
166 0, 0, | 166 0, 0, |
167 self, 'pyramid_run_logging_server') | 167 self, 'pyramid_run_logging_server') |
168 self.runLoggingServerAct.setStatusTip(self.trUtf8( | 168 self.runLoggingServerAct.setStatusTip(self.tr( |
169 'Starts the Pyramid Web server with logging')) | 169 'Starts the Pyramid Web server with logging')) |
170 self.runLoggingServerAct.setWhatsThis(self.trUtf8( | 170 self.runLoggingServerAct.setWhatsThis(self.tr( |
171 """<b>Run Server with Logging</b>""" | 171 """<b>Run Server with Logging</b>""" |
172 """<p>Starts the Pyramid Web server with logging using""" | 172 """<p>Starts the Pyramid Web server with logging using""" |
173 """ "pserve --log-file=server.log --reload development.ini".</p>""" | 173 """ "pserve --log-file=server.log --reload development.ini".</p>""" |
174 )) | 174 )) |
175 self.runLoggingServerAct.triggered[()].connect(self.__runLoggingServer) | 175 self.runLoggingServerAct.triggered.connect(self.__runLoggingServer) |
176 self.actions.append(self.runLoggingServerAct) | 176 self.actions.append(self.runLoggingServerAct) |
177 | 177 |
178 self.runBrowserAct = E5Action( | 178 self.runBrowserAct = E5Action( |
179 self.trUtf8('Run Web-Browser'), | 179 self.tr('Run Web-Browser'), |
180 self.trUtf8('Run &Web-Browser'), | 180 self.tr('Run &Web-Browser'), |
181 0, 0, | 181 0, 0, |
182 self, 'pyramid_run_browser') | 182 self, 'pyramid_run_browser') |
183 self.runBrowserAct.setStatusTip(self.trUtf8( | 183 self.runBrowserAct.setStatusTip(self.tr( |
184 'Starts the default Web-Browser with the URL of the Pyramid Web' | 184 'Starts the default Web-Browser with the URL of the Pyramid Web' |
185 ' server')) | 185 ' server')) |
186 self.runBrowserAct.setWhatsThis(self.trUtf8( | 186 self.runBrowserAct.setWhatsThis(self.tr( |
187 """<b>Run Web-Browser</b>""" | 187 """<b>Run Web-Browser</b>""" |
188 """<p>Starts the default Web-Browser with the URL of the """ | 188 """<p>Starts the default Web-Browser with the URL of the """ |
189 """Pyramid Web server.</p>""" | 189 """Pyramid Web server.</p>""" |
190 )) | 190 )) |
191 self.runBrowserAct.triggered[()].connect(self.__runBrowser) | 191 self.runBrowserAct.triggered.connect(self.__runBrowser) |
192 self.actions.append(self.runBrowserAct) | 192 self.actions.append(self.runBrowserAct) |
193 | 193 |
194 self.runPythonShellAct = E5Action( | 194 self.runPythonShellAct = E5Action( |
195 self.trUtf8('Start Pyramid Python Console'), | 195 self.tr('Start Pyramid Python Console'), |
196 self.trUtf8('Start Pyramid &Python Console'), | 196 self.tr('Start Pyramid &Python Console'), |
197 0, 0, | 197 0, 0, |
198 self, 'pyramid_python_console') | 198 self, 'pyramid_python_console') |
199 self.runPythonShellAct.setStatusTip(self.trUtf8( | 199 self.runPythonShellAct.setStatusTip(self.tr( |
200 'Starts an interactive Python interpreter')) | 200 'Starts an interactive Python interpreter')) |
201 self.runPythonShellAct.setWhatsThis(self.trUtf8( | 201 self.runPythonShellAct.setWhatsThis(self.tr( |
202 """<b>Start Pyramid Python Console</b>""" | 202 """<b>Start Pyramid Python Console</b>""" |
203 """<p>Starts an interactive Python interpreter.</p>""" | 203 """<p>Starts an interactive Python interpreter.</p>""" |
204 )) | 204 )) |
205 self.runPythonShellAct.triggered[()].connect(self.__runPythonShell) | 205 self.runPythonShellAct.triggered.connect(self.__runPythonShell) |
206 self.actions.append(self.runPythonShellAct) | 206 self.actions.append(self.runPythonShellAct) |
207 | 207 |
208 ############################## | 208 ############################## |
209 ## setup actions below ## | 209 ## setup actions below ## |
210 ############################## | 210 ############################## |
211 | 211 |
212 self.setupDevelopAct = E5Action( | 212 self.setupDevelopAct = E5Action( |
213 self.trUtf8('Setup Development Environment'), | 213 self.tr('Setup Development Environment'), |
214 self.trUtf8('Setup &Development Environment'), | 214 self.tr('Setup &Development Environment'), |
215 0, 0, | 215 0, 0, |
216 self, 'pyramid_setup_development') | 216 self, 'pyramid_setup_development') |
217 self.setupDevelopAct.setStatusTip(self.trUtf8( | 217 self.setupDevelopAct.setStatusTip(self.tr( |
218 'Setup the Pyramid project in development mode')) | 218 'Setup the Pyramid project in development mode')) |
219 self.setupDevelopAct.setWhatsThis(self.trUtf8( | 219 self.setupDevelopAct.setWhatsThis(self.tr( |
220 """<b>Setup Development Environment</b>""" | 220 """<b>Setup Development Environment</b>""" |
221 """<p>Setup the Pyramid project in development mode using""" | 221 """<p>Setup the Pyramid project in development mode using""" |
222 """ "python setup.py develop".</p>""" | 222 """ "python setup.py develop".</p>""" |
223 )) | 223 )) |
224 self.setupDevelopAct.triggered[()].connect(self.__setupDevelop) | 224 self.setupDevelopAct.triggered.connect(self.__setupDevelop) |
225 self.actions.append(self.setupDevelopAct) | 225 self.actions.append(self.setupDevelopAct) |
226 | 226 |
227 ############################### | 227 ############################### |
228 ## database actions below ## | 228 ## database actions below ## |
229 ############################### | 229 ############################### |
230 | 230 |
231 self.initializeDbAct = E5Action( | 231 self.initializeDbAct = E5Action( |
232 self.trUtf8('Initialize Database'), | 232 self.tr('Initialize Database'), |
233 self.trUtf8('Initialize &Database'), | 233 self.tr('Initialize &Database'), |
234 0, 0, | 234 0, 0, |
235 self, 'pyramid_initialize_database') | 235 self, 'pyramid_initialize_database') |
236 self.initializeDbAct.setStatusTip(self.trUtf8( | 236 self.initializeDbAct.setStatusTip(self.tr( |
237 'Initializes (or re-initializes) the database of the current' | 237 'Initializes (or re-initializes) the database of the current' |
238 ' Pyramid project')) | 238 ' Pyramid project')) |
239 self.initializeDbAct.setWhatsThis(self.trUtf8( | 239 self.initializeDbAct.setWhatsThis(self.tr( |
240 """<b>Initialize Database</b>""" | 240 """<b>Initialize Database</b>""" |
241 """<p>Initializes (or re-initializes) the database of the""" | 241 """<p>Initializes (or re-initializes) the database of the""" |
242 """ current Pyramid project.</p>""" | 242 """ current Pyramid project.</p>""" |
243 )) | 243 )) |
244 self.initializeDbAct.triggered[()].connect(self.__initializeDatabase) | 244 self.initializeDbAct.triggered.connect(self.__initializeDatabase) |
245 self.actions.append(self.initializeDbAct) | 245 self.actions.append(self.initializeDbAct) |
246 | 246 |
247 ############################### | 247 ############################### |
248 ## show actions below ## | 248 ## show actions below ## |
249 ############################### | 249 ############################### |
250 | 250 |
251 self.showViewsAct = E5Action( | 251 self.showViewsAct = E5Action( |
252 self.trUtf8('Show Matching Views'), | 252 self.tr('Show Matching Views'), |
253 self.trUtf8('Show Matching &Views'), | 253 self.tr('Show Matching &Views'), |
254 0, 0, | 254 0, 0, |
255 self, 'pyramid_show_views') | 255 self, 'pyramid_show_views') |
256 self.showViewsAct.setStatusTip(self.trUtf8( | 256 self.showViewsAct.setStatusTip(self.tr( |
257 'Show views matching a given URL')) | 257 'Show views matching a given URL')) |
258 self.showViewsAct.setWhatsThis(self.trUtf8( | 258 self.showViewsAct.setWhatsThis(self.tr( |
259 """<b>Show Matching Views</b>""" | 259 """<b>Show Matching Views</b>""" |
260 """<p>Show views matching a given URL.</p>""" | 260 """<p>Show views matching a given URL.</p>""" |
261 )) | 261 )) |
262 self.showViewsAct.triggered[()].connect(self.__showMatchingViews) | 262 self.showViewsAct.triggered.connect(self.__showMatchingViews) |
263 self.actions.append(self.showViewsAct) | 263 self.actions.append(self.showViewsAct) |
264 | 264 |
265 self.showRoutesAct = E5Action( | 265 self.showRoutesAct = E5Action( |
266 self.trUtf8('Show Routes'), | 266 self.tr('Show Routes'), |
267 self.trUtf8('Show &Routes'), | 267 self.tr('Show &Routes'), |
268 0, 0, | 268 0, 0, |
269 self, 'pyramid_show_routes') | 269 self, 'pyramid_show_routes') |
270 self.showRoutesAct.setStatusTip(self.trUtf8( | 270 self.showRoutesAct.setStatusTip(self.tr( |
271 'Show all URL dispatch routes used by a Pyramid application')) | 271 'Show all URL dispatch routes used by a Pyramid application')) |
272 self.showRoutesAct.setWhatsThis(self.trUtf8( | 272 self.showRoutesAct.setWhatsThis(self.tr( |
273 """<b>Show Routes</b>""" | 273 """<b>Show Routes</b>""" |
274 """<p>Show all URL dispatch routes used by a Pyramid application""" | 274 """<p>Show all URL dispatch routes used by a Pyramid application""" |
275 """ in the order in which they are evaluated.</p>""" | 275 """ in the order in which they are evaluated.</p>""" |
276 )) | 276 )) |
277 self.showRoutesAct.triggered[()].connect(self.__showRoutes) | 277 self.showRoutesAct.triggered.connect(self.__showRoutes) |
278 self.actions.append(self.showRoutesAct) | 278 self.actions.append(self.showRoutesAct) |
279 | 279 |
280 self.showTweensAct = E5Action( | 280 self.showTweensAct = E5Action( |
281 self.trUtf8('Show Tween Objects'), | 281 self.tr('Show Tween Objects'), |
282 self.trUtf8('Show &Tween Objects'), | 282 self.tr('Show &Tween Objects'), |
283 0, 0, | 283 0, 0, |
284 self, 'pyramid_show_routes') | 284 self, 'pyramid_show_routes') |
285 self.showTweensAct.setStatusTip(self.trUtf8( | 285 self.showTweensAct.setStatusTip(self.tr( |
286 'Show all implicit and explicit tween objects used by a Pyramid' | 286 'Show all implicit and explicit tween objects used by a Pyramid' |
287 ' application')) | 287 ' application')) |
288 self.showTweensAct.setWhatsThis(self.trUtf8( | 288 self.showTweensAct.setWhatsThis(self.tr( |
289 """<b>Show Tween Objects</b>""" | 289 """<b>Show Tween Objects</b>""" |
290 """<p>Show all implicit and explicit tween objects used by a""" | 290 """<p>Show all implicit and explicit tween objects used by a""" |
291 """ Pyramid application.</p>""" | 291 """ Pyramid application.</p>""" |
292 )) | 292 )) |
293 self.showTweensAct.triggered[()].connect(self.__showTweens) | 293 self.showTweensAct.triggered.connect(self.__showTweens) |
294 self.actions.append(self.showTweensAct) | 294 self.actions.append(self.showTweensAct) |
295 | 295 |
296 ################################## | 296 ################################## |
297 ## distribution actions below ## | 297 ## distribution actions below ## |
298 ################################## | 298 ################################## |
299 | 299 |
300 self.buildDistroAct = E5Action( | 300 self.buildDistroAct = E5Action( |
301 self.trUtf8('Build Distribution'), | 301 self.tr('Build Distribution'), |
302 self.trUtf8('Build &Distribution'), | 302 self.tr('Build &Distribution'), |
303 0, 0, | 303 0, 0, |
304 self, 'pyramid_build_distribution') | 304 self, 'pyramid_build_distribution') |
305 self.buildDistroAct.setStatusTip(self.trUtf8( | 305 self.buildDistroAct.setStatusTip(self.tr( |
306 'Builds a distribution file for the Pyramid project')) | 306 'Builds a distribution file for the Pyramid project')) |
307 self.buildDistroAct.setWhatsThis(self.trUtf8( | 307 self.buildDistroAct.setWhatsThis(self.tr( |
308 """<b>Build Distribution</b>""" | 308 """<b>Build Distribution</b>""" |
309 """<p>Builds a distribution file for the Pyramid project using""" | 309 """<p>Builds a distribution file for the Pyramid project using""" |
310 """ "python setup.py sdist".</p>""" | 310 """ "python setup.py sdist".</p>""" |
311 )) | 311 )) |
312 self.buildDistroAct.triggered[()].connect(self.__buildDistribution) | 312 self.buildDistroAct.triggered.connect(self.__buildDistribution) |
313 self.actions.append(self.buildDistroAct) | 313 self.actions.append(self.buildDistroAct) |
314 | 314 |
315 ################################## | 315 ################################## |
316 ## documentation action below ## | 316 ## documentation action below ## |
317 ################################## | 317 ################################## |
318 | 318 |
319 self.documentationAct = E5Action( | 319 self.documentationAct = E5Action( |
320 self.trUtf8('Documentation'), | 320 self.tr('Documentation'), |
321 self.trUtf8('D&ocumentation'), | 321 self.tr('D&ocumentation'), |
322 0, 0, | 322 0, 0, |
323 self, 'pyramid_documentation') | 323 self, 'pyramid_documentation') |
324 self.documentationAct.setStatusTip(self.trUtf8( | 324 self.documentationAct.setStatusTip(self.tr( |
325 'Shows the help viewer with the Pyramid documentation')) | 325 'Shows the help viewer with the Pyramid documentation')) |
326 self.documentationAct.setWhatsThis(self.trUtf8( | 326 self.documentationAct.setWhatsThis(self.tr( |
327 """<b>Documentation</b>""" | 327 """<b>Documentation</b>""" |
328 """<p>Shows the help viewer with the Pyramid documentation.</p>""" | 328 """<p>Shows the help viewer with the Pyramid documentation.</p>""" |
329 )) | 329 )) |
330 self.documentationAct.triggered[()].connect(self.__showDocumentation) | 330 self.documentationAct.triggered.connect(self.__showDocumentation) |
331 self.actions.append(self.documentationAct) | 331 self.actions.append(self.documentationAct) |
332 | 332 |
333 ############################## | 333 ############################## |
334 ## about action below ## | 334 ## about action below ## |
335 ############################## | 335 ############################## |
336 | 336 |
337 self.aboutPyramidAct = E5Action( | 337 self.aboutPyramidAct = E5Action( |
338 self.trUtf8('About Pyramid'), | 338 self.tr('About Pyramid'), |
339 self.trUtf8('About P&yramid'), | 339 self.tr('About P&yramid'), |
340 0, 0, | 340 0, 0, |
341 self, 'pyramid_about') | 341 self, 'pyramid_about') |
342 self.aboutPyramidAct.setStatusTip(self.trUtf8( | 342 self.aboutPyramidAct.setStatusTip(self.tr( |
343 'Shows some information about Pyramid')) | 343 'Shows some information about Pyramid')) |
344 self.aboutPyramidAct.setWhatsThis(self.trUtf8( | 344 self.aboutPyramidAct.setWhatsThis(self.tr( |
345 """<b>About Pyramid</b>""" | 345 """<b>About Pyramid</b>""" |
346 """<p>Shows some information about Pyramid.</p>""" | 346 """<p>Shows some information about Pyramid.</p>""" |
347 )) | 347 )) |
348 self.aboutPyramidAct.triggered[()].connect(self.__pyramidInfo) | 348 self.aboutPyramidAct.triggered.connect(self.__pyramidInfo) |
349 self.actions.append(self.aboutPyramidAct) | 349 self.actions.append(self.aboutPyramidAct) |
350 | 350 |
351 self.__setCurrentProject(None) | 351 self.__setCurrentProject(None) |
352 | 352 |
353 def initMenu(self): | 353 def initMenu(self): |
356 | 356 |
357 @return the menu generated (QMenu) | 357 @return the menu generated (QMenu) |
358 """ | 358 """ |
359 self.__menus = {} # clear menus references | 359 self.__menus = {} # clear menus references |
360 | 360 |
361 menu = QMenu(self.trUtf8('P&yramid'), self.__ui) | 361 menu = QMenu(self.tr('P&yramid'), self.__ui) |
362 menu.setTearOffEnabled(True) | 362 menu.setTearOffEnabled(True) |
363 | 363 |
364 menu.addAction(self.selectProjectAct) | 364 menu.addAction(self.selectProjectAct) |
365 menu.addSeparator() | 365 menu.addSeparator() |
366 menu.addAction(self.runServerAct) | 366 menu.addAction(self.runServerAct) |
415 Public method to register the open hook to open a translations file | 415 Public method to register the open hook to open a translations file |
416 in a translations editor. | 416 in a translations editor. |
417 """ | 417 """ |
418 if self.__hooksInstalled: | 418 if self.__hooksInstalled: |
419 editor = self.__plugin.getPreferences("TranslationsEditor") | 419 editor = self.__plugin.getPreferences("TranslationsEditor") |
420 try: | 420 if editor: |
421 if editor: | 421 self.__translationsBrowser.addHookMethodAndMenuEntry( |
422 self.__translationsBrowser.addHookMethodAndMenuEntry( | 422 "open", self.openPOEditor, |
423 "open", self.openPOEditor, | 423 self.tr("Open with {0}").format( |
424 self.trUtf8("Open with {0}").format( | 424 os.path.basename(editor))) |
425 os.path.basename(editor))) | 425 else: |
426 else: | 426 self.__translationsBrowser.removeHookMethod("open") |
427 self.__translationsBrowser.removeHookMethod("open") | |
428 except KeyError: | |
429 # ignore for older eric5 versions | |
430 pass | |
431 | 427 |
432 def projectOpenedHooks(self): | 428 def projectOpenedHooks(self): |
433 """ | 429 """ |
434 Public method to add our hook methods. | 430 Public method to add our hook methods. |
435 """ | 431 """ |
436 if self.__e5project.getProjectType() == "Pyramid": | 432 if self.__e5project.getProjectType() == "Pyramid": |
437 self.__formsBrowser = \ | 433 self.__formsBrowser = \ |
438 e5App().getObject("ProjectBrowser").getProjectBrowser("forms") | 434 e5App().getObject("ProjectBrowser").getProjectBrowser("forms") |
439 self.__formsBrowser.addHookMethodAndMenuEntry( | 435 self.__formsBrowser.addHookMethodAndMenuEntry( |
440 "newForm", self.newForm, self.trUtf8("New template...")) | 436 "newForm", self.newForm, self.tr("New template...")) |
441 | 437 |
442 if self.__e5project.getProjectLanguage() == "Python2": | 438 if self.__e5project.getProjectLanguage() == "Python2": |
443 # Babel and lingua are not yet available for Python 3 | 439 # Babel and lingua are not yet available for Python 3 |
444 self.__e5project.projectLanguageAddedByCode.connect( | 440 self.__e5project.projectLanguageAddedByCode.connect( |
445 self.__projectLanguageAdded) | 441 self.__projectLanguageAdded) |
446 self.__translationsBrowser = \ | 442 self.__translationsBrowser = \ |
447 e5App().getObject("ProjectBrowser")\ | 443 e5App().getObject("ProjectBrowser")\ |
448 .getProjectBrowser("translations") | 444 .getProjectBrowser("translations") |
449 self.__translationsBrowser.addHookMethodAndMenuEntry( | 445 self.__translationsBrowser.addHookMethodAndMenuEntry( |
450 "extractMessages", self.extractMessages, | 446 "extractMessages", self.extractMessages, |
451 self.trUtf8("Extract Messages")) | 447 self.tr("Extract Messages")) |
452 self.__translationsBrowser.addHookMethodAndMenuEntry( | 448 self.__translationsBrowser.addHookMethodAndMenuEntry( |
453 "releaseAll", self.compileCatalogs, | 449 "releaseAll", self.compileCatalogs, |
454 self.trUtf8("Compile All Catalogs")) | 450 self.tr("Compile All Catalogs")) |
455 self.__translationsBrowser.addHookMethodAndMenuEntry( | 451 self.__translationsBrowser.addHookMethodAndMenuEntry( |
456 "releaseSelected", self.compileSelectedCatalogs, | 452 "releaseSelected", self.compileSelectedCatalogs, |
457 self.trUtf8("Compile Selected Catalogs")) | 453 self.tr("Compile Selected Catalogs")) |
458 self.__translationsBrowser.addHookMethodAndMenuEntry( | 454 self.__translationsBrowser.addHookMethodAndMenuEntry( |
459 "generateAll", self.updateCatalogs, | 455 "generateAll", self.updateCatalogs, |
460 self.trUtf8("Update All Catalogs")) | 456 self.tr("Update All Catalogs")) |
461 self.__translationsBrowser.addHookMethodAndMenuEntry( | 457 self.__translationsBrowser.addHookMethodAndMenuEntry( |
462 "generateSelected", self.updateSelectedCatalogs, | 458 "generateSelected", self.updateSelectedCatalogs, |
463 self.trUtf8("Update Selected Catalogs")) | 459 self.tr("Update Selected Catalogs")) |
464 | 460 |
465 self.__hooksInstalled = True | 461 self.__hooksInstalled = True |
466 | 462 |
467 self.registerOpenHook() | 463 self.registerOpenHook() |
468 | 464 |
479 self.__translationsBrowser.removeHookMethod("extractMessages") | 475 self.__translationsBrowser.removeHookMethod("extractMessages") |
480 self.__translationsBrowser.removeHookMethod("releaseAll") | 476 self.__translationsBrowser.removeHookMethod("releaseAll") |
481 self.__translationsBrowser.removeHookMethod("releaseSelected") | 477 self.__translationsBrowser.removeHookMethod("releaseSelected") |
482 self.__translationsBrowser.removeHookMethod("generateAll") | 478 self.__translationsBrowser.removeHookMethod("generateAll") |
483 self.__translationsBrowser.removeHookMethod("generateSelected") | 479 self.__translationsBrowser.removeHookMethod("generateSelected") |
484 try: | 480 self.__translationsBrowser.removeHookMethod("open") |
485 self.__translationsBrowser.removeHookMethod("open") | |
486 except KeyError: | |
487 # ignore for older eric5 versions | |
488 pass | |
489 self.__translationsBrowser = None | 481 self.__translationsBrowser = None |
490 | 482 |
491 self.__hooksInstalled = False | 483 self.__hooksInstalled = False |
492 | 484 |
493 def newForm(self, path): | 485 def newForm(self, path): |
500 | 492 |
501 dlg = FormSelectionDialog() | 493 dlg = FormSelectionDialog() |
502 if dlg.exec_() == QDialog.Accepted: | 494 if dlg.exec_() == QDialog.Accepted: |
503 template = dlg.getTemplateText() | 495 template = dlg.getTemplateText() |
504 | 496 |
505 filter = self.trUtf8( | 497 filter = self.tr( |
506 "Chameleon Templates (*.pt);;" | 498 "Chameleon Templates (*.pt);;" |
507 "Chameleon Text Templates (*.txt);;" | 499 "Chameleon Text Templates (*.txt);;" |
508 "Mako Templates (*.mako);;" | 500 "Mako Templates (*.mako);;" |
509 "Mako Templates (*.mak);;" | 501 "Mako Templates (*.mak);;" |
510 "HTML Files (*.html);;" | 502 "HTML Files (*.html);;" |
511 "HTML Files (*.htm);;" | 503 "HTML Files (*.htm);;" |
512 "All Files (*)") | 504 "All Files (*)") |
513 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( | 505 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
514 self.__ui, | 506 self.__ui, |
515 self.trUtf8("New Form"), | 507 self.tr("New Form"), |
516 path, | 508 path, |
517 filter, | 509 filter, |
518 None, | 510 None, |
519 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) | 511 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
520 if fname: | 512 if fname: |
525 fname += ex | 517 fname += ex |
526 | 518 |
527 if os.path.exists(fname): | 519 if os.path.exists(fname): |
528 res = E5MessageBox.yesNo( | 520 res = E5MessageBox.yesNo( |
529 self.__ui, | 521 self.__ui, |
530 self.trUtf8("New Form"), | 522 self.tr("New Form"), |
531 self.trUtf8("""The file already exists! Overwrite""" | 523 self.tr("""The file already exists! Overwrite""" |
532 """ it?"""), | 524 """ it?"""), |
533 icon=E5MessageBox.Warning) | 525 icon=E5MessageBox.Warning) |
534 if not res: | 526 if not res: |
535 # user selected to not overwrite | 527 # user selected to not overwrite |
536 return | 528 return |
537 | 529 |
540 f.write(template) | 532 f.write(template) |
541 f.close() | 533 f.close() |
542 except IOError as e: | 534 except IOError as e: |
543 E5MessageBox.critical( | 535 E5MessageBox.critical( |
544 self.__ui, | 536 self.__ui, |
545 self.trUtf8("New Form"), | 537 self.tr("New Form"), |
546 self.trUtf8("<p>The new form file <b>{0}</b> could" | 538 self.tr("<p>The new form file <b>{0}</b> could" |
547 " not be created.<br/> Problem: {1}</p>") | 539 " not be created.<br/> Problem: {1}</p>") |
548 .format(fname, e)) | 540 .format(fname, e)) |
549 return | 541 return |
550 | 542 |
551 self.__e5project.appendFile(fname) | 543 self.__e5project.appendFile(fname) |
552 self.__formsBrowser.sourceFile.emit(fname) | 544 self.__formsBrowser.sourceFile.emit(fname) |
755 version = self.getPyramidVersion() | 747 version = self.getPyramidVersion() |
756 url = "http://www.pylonsproject.org/projects/pyramid/about" | 748 url = "http://www.pylonsproject.org/projects/pyramid/about" |
757 | 749 |
758 msgBox = E5MessageBox.E5MessageBox( | 750 msgBox = E5MessageBox.E5MessageBox( |
759 E5MessageBox.Question, | 751 E5MessageBox.Question, |
760 self.trUtf8("About Pyramid"), | 752 self.tr("About Pyramid"), |
761 self.trUtf8( | 753 self.tr( |
762 "<p>Pyramid is a high-level Python Web framework that" | 754 "<p>Pyramid is a high-level Python Web framework that" |
763 " encourages rapid development and clean, pragmatic" | 755 " encourages rapid development and clean, pragmatic" |
764 " design.</p>" | 756 " design.</p>" |
765 "<p><table>" | 757 "<p><table>" |
766 "<tr><td>Version:</td><td>{0}</td></tr>" | 758 "<tr><td>Version:</td><td>{0}</td></tr>" |
834 args.append("--interactive") | 826 args.append("--interactive") |
835 if simulate: | 827 if simulate: |
836 args.append("--simulate") | 828 args.append("--simulate") |
837 args.append("--scaffold={0}".format(scaffold)) | 829 args.append("--scaffold={0}".format(scaffold)) |
838 args.append(project) | 830 args.append(project) |
839 dlg = PyramidDialog(self.trUtf8("Create Pyramid Project"), | 831 dlg = PyramidDialog(self.tr("Create Pyramid Project"), |
840 linewrap=False, parent=self.__ui) | 832 linewrap=False, parent=self.__ui) |
841 if dlg.startProcess(cmd, args, self.__e5project.getProjectPath()): | 833 if dlg.startProcess(cmd, args, self.__e5project.getProjectPath()): |
842 dlg.exec_() | 834 dlg.exec_() |
843 if dlg.normalExit() and not simulate: | 835 if dlg.normalExit() and not simulate: |
844 # search for files created by pcreate and add them to the | 836 # search for files created by pcreate and add them to the |
895 cur = 0 | 887 cur = 0 |
896 else: | 888 else: |
897 cur = 0 | 889 cur = 0 |
898 project, ok = QInputDialog.getItem( | 890 project, ok = QInputDialog.getItem( |
899 self.__ui, | 891 self.__ui, |
900 self.trUtf8("Select Pyramid Project"), | 892 self.tr("Select Pyramid Project"), |
901 self.trUtf8("Select the Pyramid project to work with."), | 893 self.tr("Select the Pyramid project to work with."), |
902 projects, | 894 projects, |
903 cur, False) | 895 cur, False) |
904 if not ok: | 896 if not ok: |
905 projects = None | 897 projects = None |
906 self.__setCurrentProject(project) | 898 self.__setCurrentProject(project) |
932 self.__currentProject = None | 924 self.__currentProject = None |
933 else: | 925 else: |
934 self.__currentProject = project | 926 self.__currentProject = project |
935 | 927 |
936 if self.__currentProject is None: | 928 if self.__currentProject is None: |
937 curProject = self.trUtf8("None") | 929 curProject = self.tr("None") |
938 else: | 930 else: |
939 curProject = self.__currentProject | 931 curProject = self.__currentProject |
940 self.selectProjectAct.setText( | 932 self.selectProjectAct.setText( |
941 self.trUtf8('&Current Pyramid Project ({0})').format(curProject)) | 933 self.tr('&Current Pyramid Project ({0})').format(curProject)) |
942 | 934 |
943 if self.__currentProject is None: | 935 if self.__currentProject is None: |
944 self.__e5project.pdata["TRANSLATIONPATTERN"] = [] | 936 self.__e5project.pdata["TRANSLATIONPATTERN"] = [] |
945 else: | 937 else: |
946 lowerProject = self.__project().lower() | 938 lowerProject = self.__project().lower() |
997 try: | 989 try: |
998 projectPath = self.__projectPath() | 990 projectPath = self.__projectPath() |
999 except PyramidNoProjectSelectedException: | 991 except PyramidNoProjectSelectedException: |
1000 E5MessageBox.warning( | 992 E5MessageBox.warning( |
1001 self.__ui, | 993 self.__ui, |
1002 self.trUtf8('Run Server'), | 994 self.tr('Run Server'), |
1003 self.trUtf8('No current Pyramid project selected or no' | 995 self.tr('No current Pyramid project selected or no' |
1004 ' Pyramid project created yet. Aborting...')) | 996 ' Pyramid project created yet. Aborting...')) |
1005 return | 997 return |
1006 | 998 |
1007 args = Utilities.parseOptionString(consoleCmd) | 999 args = Utilities.parseOptionString(consoleCmd) |
1008 args[0] = Utilities.getExecutablePath(args[0]) | 1000 args[0] = Utilities.getExecutablePath(args[0]) |
1009 args.append(self.getPyramidCommand("pserve")) | 1001 args.append(self.getPyramidCommand("pserve")) |
1025 self.__serverProc.start(args[0], args[1:]) | 1017 self.__serverProc.start(args[0], args[1:]) |
1026 serverProcStarted = self.__serverProc.waitForStarted() | 1018 serverProcStarted = self.__serverProc.waitForStarted() |
1027 if not serverProcStarted: | 1019 if not serverProcStarted: |
1028 E5MessageBox.critical( | 1020 E5MessageBox.critical( |
1029 self.__ui, | 1021 self.__ui, |
1030 self.trUtf8('Process Generation Error'), | 1022 self.tr('Process Generation Error'), |
1031 self.trUtf8('The Pyramid server could not be started.')) | 1023 self.tr('The Pyramid server could not be started.')) |
1032 | 1024 |
1033 def __runLoggingServer(self): | 1025 def __runLoggingServer(self): |
1034 """ | 1026 """ |
1035 Private slot to start the Pyramid Web server with logging. | 1027 Private slot to start the Pyramid Web server with logging. |
1036 """ | 1028 """ |
1054 try: | 1046 try: |
1055 projectPath = self.__projectPath() | 1047 projectPath = self.__projectPath() |
1056 except PyramidNoProjectSelectedException: | 1048 except PyramidNoProjectSelectedException: |
1057 E5MessageBox.warning( | 1049 E5MessageBox.warning( |
1058 self.__ui, | 1050 self.__ui, |
1059 self.trUtf8('Run Web-Browser'), | 1051 self.tr('Run Web-Browser'), |
1060 self.trUtf8('No current Pyramid project selected or no Pyramid' | 1052 self.tr('No current Pyramid project selected or no Pyramid' |
1061 ' project created yet. Aborting...')) | 1053 ' project created yet. Aborting...')) |
1062 return | 1054 return |
1063 | 1055 |
1064 config = configparser.ConfigParser() | 1056 config = configparser.ConfigParser() |
1065 config.read(os.path.join(projectPath, "development.ini")) | 1057 config.read(os.path.join(projectPath, "development.ini")) |
1066 try: | 1058 try: |
1070 url = QUrl("http://localhost:{0}".format(port)) | 1062 url = QUrl("http://localhost:{0}".format(port)) |
1071 res = QDesktopServices.openUrl(url) | 1063 res = QDesktopServices.openUrl(url) |
1072 if not res: | 1064 if not res: |
1073 E5MessageBox.critical( | 1065 E5MessageBox.critical( |
1074 self.__ui, | 1066 self.__ui, |
1075 self.trUtf8('Run Web-Browser'), | 1067 self.tr('Run Web-Browser'), |
1076 self.trUtf8('Could not start the web-browser for the URL' | 1068 self.tr('Could not start the web-browser for the URL' |
1077 ' "{0}".').format(url.toString())) | 1069 ' "{0}".').format(url.toString())) |
1078 | 1070 |
1079 def __runPythonShell(self): | 1071 def __runPythonShell(self): |
1080 """ | 1072 """ |
1081 Private slot to start a Python console for a Pyramid project. | 1073 Private slot to start a Python console for a Pyramid project. |
1082 """ | 1074 """ |
1086 try: | 1078 try: |
1087 projectPath = self.__projectPath() | 1079 projectPath = self.__projectPath() |
1088 except PyramidNoProjectSelectedException: | 1080 except PyramidNoProjectSelectedException: |
1089 E5MessageBox.warning( | 1081 E5MessageBox.warning( |
1090 self.__ui, | 1082 self.__ui, |
1091 self.trUtf8('Start Pyramid Python Console'), | 1083 self.tr('Start Pyramid Python Console'), |
1092 self.trUtf8('No current Pyramid project selected or no' | 1084 self.tr('No current Pyramid project selected or no' |
1093 ' Pyramid project created yet. Aborting...')) | 1085 ' Pyramid project created yet. Aborting...')) |
1094 return | 1086 return |
1095 | 1087 |
1096 args = Utilities.parseOptionString(consoleCmd) | 1088 args = Utilities.parseOptionString(consoleCmd) |
1097 args[0] = Utilities.getExecutablePath(args[0]) | 1089 args[0] = Utilities.getExecutablePath(args[0]) |
1098 args.append(self.getPyramidCommand("pshell")) | 1090 args.append(self.getPyramidCommand("pshell")) |
1109 started, pid = QProcess.startDetached( | 1101 started, pid = QProcess.startDetached( |
1110 args[0], args[1:], projectPath) | 1102 args[0], args[1:], projectPath) |
1111 if not started: | 1103 if not started: |
1112 E5MessageBox.critical( | 1104 E5MessageBox.critical( |
1113 self.__ui, | 1105 self.__ui, |
1114 self.trUtf8('Process Generation Error'), | 1106 self.tr('Process Generation Error'), |
1115 self.trUtf8('The Pyramid Shell process could not be' | 1107 self.tr('The Pyramid Shell process could not be' |
1116 ' started.')) | 1108 ' started.')) |
1117 | 1109 |
1118 ################################################################## | 1110 ################################################################## |
1119 ## slots below implement setup functions | 1111 ## slots below implement setup functions |
1120 ################################################################## | 1112 ################################################################## |
1121 | 1113 |
1122 def __setupDevelop(self): | 1114 def __setupDevelop(self): |
1123 """ | 1115 """ |
1124 Private slot to set up the development environment for the current | 1116 Private slot to set up the development environment for the current |
1125 project. | 1117 project. |
1126 """ | 1118 """ |
1127 title = self.trUtf8("Setup Development Environment") | 1119 title = self.tr("Setup Development Environment") |
1128 try: | 1120 try: |
1129 wd = self.__projectPath() | 1121 wd = self.__projectPath() |
1130 except PyramidNoProjectSelectedException: | 1122 except PyramidNoProjectSelectedException: |
1131 E5MessageBox.warning( | 1123 E5MessageBox.warning( |
1132 self.__ui, | 1124 self.__ui, |
1133 title, | 1125 title, |
1134 self.trUtf8('No current Pyramid project selected or no Pyramid' | 1126 self.tr('No current Pyramid project selected or no Pyramid' |
1135 ' project created yet. Aborting...')) | 1127 ' project created yet. Aborting...')) |
1136 return | 1128 return |
1137 | 1129 |
1138 cmd = self.getPythonCommand() | 1130 cmd = self.getPythonCommand() |
1139 args = [] | 1131 args = [] |
1140 args.append("setup.py") | 1132 args.append("setup.py") |
1141 args.append("develop") | 1133 args.append("develop") |
1142 | 1134 |
1143 dia = PyramidDialog( | 1135 dia = PyramidDialog( |
1144 title, | 1136 title, |
1145 msgSuccess=self.trUtf8("Pyramid development environment setup" | 1137 msgSuccess=self.tr("Pyramid development environment setup" |
1146 " successfully.")) | 1138 " successfully.")) |
1147 res = dia.startProcess(cmd, args, wd) | 1139 res = dia.startProcess(cmd, args, wd) |
1148 if res: | 1140 if res: |
1149 dia.exec_() | 1141 dia.exec_() |
1150 initCmd = self.__getInitDbCommand() | 1142 initCmd = self.__getInitDbCommand() |
1151 self.initializeDbAct.setEnabled(os.path.exists(initCmd)) | 1143 self.initializeDbAct.setEnabled(os.path.exists(initCmd)) |
1157 def __buildDistribution(self): | 1149 def __buildDistribution(self): |
1158 """ | 1150 """ |
1159 Private slot to build a distribution file for the current Pyramid | 1151 Private slot to build a distribution file for the current Pyramid |
1160 project. | 1152 project. |
1161 """ | 1153 """ |
1162 title = self.trUtf8("Build Distribution File") | 1154 title = self.tr("Build Distribution File") |
1163 try: | 1155 try: |
1164 projectPath = self.__projectPath() | 1156 projectPath = self.__projectPath() |
1165 except PyramidNoProjectSelectedException: | 1157 except PyramidNoProjectSelectedException: |
1166 E5MessageBox.warning( | 1158 E5MessageBox.warning( |
1167 self.__ui, | 1159 self.__ui, |
1168 title, | 1160 title, |
1169 self.trUtf8('No current Pyramid project selected or no Pyramid' | 1161 self.tr('No current Pyramid project selected or no Pyramid' |
1170 ' project created yet. Aborting...')) | 1162 ' project created yet. Aborting...')) |
1171 return | 1163 return |
1172 | 1164 |
1173 from .DistributionTypeSelectionDialog import \ | 1165 from .DistributionTypeSelectionDialog import \ |
1174 DistributionTypeSelectionDialog | 1166 DistributionTypeSelectionDialog |
1175 | 1167 |
1183 if formats: | 1175 if formats: |
1184 args.append("--formats={0}".format(','.join(formats))) | 1176 args.append("--formats={0}".format(','.join(formats))) |
1185 | 1177 |
1186 dia = PyramidDialog( | 1178 dia = PyramidDialog( |
1187 title, | 1179 title, |
1188 msgSuccess=self.trUtf8("Python distribution file built" | 1180 msgSuccess=self.tr("Python distribution file built" |
1189 " successfully.")) | 1181 " successfully.")) |
1190 res = dia.startProcess(cmd, args, projectPath) | 1182 res = dia.startProcess(cmd, args, projectPath) |
1191 if res: | 1183 if res: |
1192 dia.exec_() | 1184 dia.exec_() |
1193 | 1185 |
1194 ################################################################## | 1186 ################################################################## |
1205 cmd = "initialize_{0}_db".format(self.__project()) | 1197 cmd = "initialize_{0}_db".format(self.__project()) |
1206 return self.getPyramidCommand(cmd) | 1198 return self.getPyramidCommand(cmd) |
1207 except PyramidNoProjectSelectedException: | 1199 except PyramidNoProjectSelectedException: |
1208 E5MessageBox.warning( | 1200 E5MessageBox.warning( |
1209 self.__ui, | 1201 self.__ui, |
1210 self.trUtf8("Initialize Database"), | 1202 self.tr("Initialize Database"), |
1211 self.trUtf8('No current Pyramid project selected or no Pyramid' | 1203 self.tr('No current Pyramid project selected or no Pyramid' |
1212 ' project created yet. Aborting...')) | 1204 ' project created yet. Aborting...')) |
1213 return "" | 1205 return "" |
1214 | 1206 |
1215 def __initializeDatabase(self): | 1207 def __initializeDatabase(self): |
1216 """ | 1208 """ |
1217 Private slot to initialize the database of the Pyramid project. | 1209 Private slot to initialize the database of the Pyramid project. |
1218 """ | 1210 """ |
1219 title = self.trUtf8("Initialize Database") | 1211 title = self.tr("Initialize Database") |
1220 try: | 1212 try: |
1221 projectPath = self.__projectPath() | 1213 projectPath = self.__projectPath() |
1222 except PyramidNoProjectSelectedException: | 1214 except PyramidNoProjectSelectedException: |
1223 E5MessageBox.warning( | 1215 E5MessageBox.warning( |
1224 self.__ui, | 1216 self.__ui, |
1225 title, | 1217 title, |
1226 self.trUtf8('No current Pyramid project selected or no Pyramid' | 1218 self.tr('No current Pyramid project selected or no Pyramid' |
1227 ' project created yet. Aborting...')) | 1219 ' project created yet. Aborting...')) |
1228 return | 1220 return |
1229 | 1221 |
1230 cmd = self.__getInitDbCommand() | 1222 cmd = self.__getInitDbCommand() |
1231 args = [] | 1223 args = [] |
1232 args.append("development.ini") | 1224 args.append("development.ini") |
1233 | 1225 |
1234 dia = PyramidDialog( | 1226 dia = PyramidDialog( |
1235 title, | 1227 title, |
1236 msgSuccess=self.trUtf8("Database initialized successfully.")) | 1228 msgSuccess=self.tr("Database initialized successfully.")) |
1237 res = dia.startProcess(cmd, args, projectPath) | 1229 res = dia.startProcess(cmd, args, projectPath) |
1238 if res: | 1230 if res: |
1239 dia.exec_() | 1231 dia.exec_() |
1240 | 1232 |
1241 ################################################################## | 1233 ################################################################## |
1244 | 1236 |
1245 def __showMatchingViews(self): | 1237 def __showMatchingViews(self): |
1246 """ | 1238 """ |
1247 Private slot showing all views that would match a given URL. | 1239 Private slot showing all views that would match a given URL. |
1248 """ | 1240 """ |
1249 title = self.trUtf8("Show Matching Views") | 1241 title = self.tr("Show Matching Views") |
1250 try: | 1242 try: |
1251 projectPath = self.__projectPath() | 1243 projectPath = self.__projectPath() |
1252 except PyramidNoProjectSelectedException: | 1244 except PyramidNoProjectSelectedException: |
1253 E5MessageBox.warning( | 1245 E5MessageBox.warning( |
1254 self.__ui, | 1246 self.__ui, |
1255 title, | 1247 title, |
1256 self.trUtf8('No current Pyramid project selected or no Pyramid' | 1248 self.tr('No current Pyramid project selected or no Pyramid' |
1257 ' project created yet. Aborting...')) | 1249 ' project created yet. Aborting...')) |
1258 return | 1250 return |
1259 | 1251 |
1260 url, ok = QInputDialog.getText( | 1252 url, ok = QInputDialog.getText( |
1261 self.__ui, | 1253 self.__ui, |
1262 self.trUtf8("Show Matching Views"), | 1254 self.tr("Show Matching Views"), |
1263 self.trUtf8("Enter the URL to be matched:"), | 1255 self.tr("Enter the URL to be matched:"), |
1264 QLineEdit.Normal, | 1256 QLineEdit.Normal, |
1265 "/") | 1257 "/") |
1266 if not ok or url == "": | 1258 if not ok or url == "": |
1267 return | 1259 return |
1268 | 1260 |
1278 | 1270 |
1279 def __showRoutes(self): | 1271 def __showRoutes(self): |
1280 """ | 1272 """ |
1281 Private slot showing all URL dispatch routes. | 1273 Private slot showing all URL dispatch routes. |
1282 """ | 1274 """ |
1283 title = self.trUtf8("Show Routes") | 1275 title = self.tr("Show Routes") |
1284 try: | 1276 try: |
1285 projectPath = self.__projectPath() | 1277 projectPath = self.__projectPath() |
1286 except PyramidNoProjectSelectedException: | 1278 except PyramidNoProjectSelectedException: |
1287 E5MessageBox.warning( | 1279 E5MessageBox.warning( |
1288 self.__ui, | 1280 self.__ui, |
1289 title, | 1281 title, |
1290 self.trUtf8('No current Pyramid project selected or no Pyramid' | 1282 self.tr('No current Pyramid project selected or no Pyramid' |
1291 ' project created yet. Aborting...')) | 1283 ' project created yet. Aborting...')) |
1292 return | 1284 return |
1293 | 1285 |
1294 from .PyramidRoutesDialog import PyramidRoutesDialog | 1286 from .PyramidRoutesDialog import PyramidRoutesDialog |
1295 | 1287 |
1296 dia = PyramidRoutesDialog(self) | 1288 dia = PyramidRoutesDialog(self) |
1300 | 1292 |
1301 def __showTweens(self): | 1293 def __showTweens(self): |
1302 """ | 1294 """ |
1303 Private slot showing all implicit and explicit tween objects. | 1295 Private slot showing all implicit and explicit tween objects. |
1304 """ | 1296 """ |
1305 title = self.trUtf8("Show Tween Objects") | 1297 title = self.tr("Show Tween Objects") |
1306 try: | 1298 try: |
1307 projectPath = self.__projectPath() | 1299 projectPath = self.__projectPath() |
1308 except PyramidNoProjectSelectedException: | 1300 except PyramidNoProjectSelectedException: |
1309 E5MessageBox.warning( | 1301 E5MessageBox.warning( |
1310 self.__ui, | 1302 self.__ui, |
1311 title, | 1303 title, |
1312 self.trUtf8('No current Pyramid project selected or no Pyramid' | 1304 self.tr('No current Pyramid project selected or no Pyramid' |
1313 ' project created yet. Aborting...')) | 1305 ' project created yet. Aborting...')) |
1314 return | 1306 return |
1315 | 1307 |
1316 cmd = self.getPyramidCommand("ptweens") | 1308 cmd = self.getPyramidCommand("ptweens") |
1317 args = [] | 1309 args = [] |
1318 args.append("development.ini") | 1310 args.append("development.ini") |
1396 | 1388 |
1397 def extractMessages(self): | 1389 def extractMessages(self): |
1398 """ | 1390 """ |
1399 Public method to extract the messages catalog template file. | 1391 Public method to extract the messages catalog template file. |
1400 """ | 1392 """ |
1401 title = self.trUtf8("Extract messages") | 1393 title = self.tr("Extract messages") |
1402 try: | 1394 try: |
1403 projectPath = self.__projectPath() | 1395 projectPath = self.__projectPath() |
1404 except PyramidNoProjectSelectedException: | 1396 except PyramidNoProjectSelectedException: |
1405 E5MessageBox.warning( | 1397 E5MessageBox.warning( |
1406 self.__ui, | 1398 self.__ui, |
1407 title, | 1399 title, |
1408 self.trUtf8('No current Pyramid project selected or no Pyramid' | 1400 self.tr('No current Pyramid project selected or no Pyramid' |
1409 ' project created yet. Aborting...')) | 1401 ' project created yet. Aborting...')) |
1410 return | 1402 return |
1411 | 1403 |
1412 config = configparser.ConfigParser() | 1404 config = configparser.ConfigParser() |
1413 config.read(os.path.join(projectPath, "setup.cfg")) | 1405 config.read(os.path.join(projectPath, "setup.cfg")) |
1414 try: | 1406 try: |
1415 potFile = config.get("extract_messages", "output_file") | 1407 potFile = config.get("extract_messages", "output_file") |
1416 except configparser.NoSectionError: | 1408 except configparser.NoSectionError: |
1417 E5MessageBox.warning( | 1409 E5MessageBox.warning( |
1418 self.__ui, | 1410 self.__ui, |
1419 title, | 1411 title, |
1420 self.trUtf8('No setup.cfg found or no "extract_messages"' | 1412 self.tr('No setup.cfg found or no "extract_messages"' |
1421 ' section found in setup.cfg.')) | 1413 ' section found in setup.cfg.')) |
1422 return | 1414 return |
1423 except configparser.NoOptionError: | 1415 except configparser.NoOptionError: |
1424 E5MessageBox.warning( | 1416 E5MessageBox.warning( |
1425 self.__ui, | 1417 self.__ui, |
1426 title, | 1418 title, |
1427 self.trUtf8('No "output_file" option found in setup.cfg.')) | 1419 self.tr('No "output_file" option found in setup.cfg.')) |
1428 return | 1420 return |
1429 | 1421 |
1430 try: | 1422 try: |
1431 path = os.path.join(projectPath, os.path.dirname(potFile)) | 1423 path = os.path.join(projectPath, os.path.dirname(potFile)) |
1432 os.makedirs(path) | 1424 os.makedirs(path) |
1438 args.append("setup.py") | 1430 args.append("setup.py") |
1439 args.append("extract_messages") | 1431 args.append("extract_messages") |
1440 | 1432 |
1441 dia = PyramidDialog( | 1433 dia = PyramidDialog( |
1442 title, | 1434 title, |
1443 msgSuccess=self.trUtf8("\nMessages extracted successfully.")) | 1435 msgSuccess=self.tr("\nMessages extracted successfully.")) |
1444 res = dia.startProcess(cmd, args, projectPath) | 1436 res = dia.startProcess(cmd, args, projectPath) |
1445 if res: | 1437 if res: |
1446 dia.exec_() | 1438 dia.exec_() |
1447 self.__e5project.appendFile(os.path.join(projectPath, potFile)) | 1439 self.__e5project.appendFile(os.path.join(projectPath, potFile)) |
1448 | 1440 |
1450 """ | 1442 """ |
1451 Private slot handling the addition of a new language. | 1443 Private slot handling the addition of a new language. |
1452 | 1444 |
1453 @param code language code of the new language (string) | 1445 @param code language code of the new language (string) |
1454 """ | 1446 """ |
1455 title = self.trUtf8("Initializing message catalog for '{0}'")\ | 1447 title = self.tr("Initializing message catalog for '{0}'")\ |
1456 .format(code) | 1448 .format(code) |
1457 try: | 1449 try: |
1458 projectPath = self.__projectPath() | 1450 projectPath = self.__projectPath() |
1459 except PyramidNoProjectSelectedException: | 1451 except PyramidNoProjectSelectedException: |
1460 E5MessageBox.warning( | 1452 E5MessageBox.warning( |
1461 self.__ui, | 1453 self.__ui, |
1462 title, | 1454 title, |
1463 self.trUtf8('No current Pyramid project selected or no Pyramid' | 1455 self.tr('No current Pyramid project selected or no Pyramid' |
1464 ' project created yet. Aborting...')) | 1456 ' project created yet. Aborting...')) |
1465 return | 1457 return |
1466 | 1458 |
1467 cmd = self.getPythonCommand() | 1459 cmd = self.getPythonCommand() |
1468 args = [] | 1460 args = [] |
1469 args.append("setup.py") | 1461 args.append("setup.py") |
1471 args.append("-l") | 1463 args.append("-l") |
1472 args.append(code) | 1464 args.append(code) |
1473 | 1465 |
1474 dia = PyramidDialog( | 1466 dia = PyramidDialog( |
1475 title, | 1467 title, |
1476 msgSuccess=self.trUtf8("\nMessage catalog initialized" | 1468 msgSuccess=self.tr("\nMessage catalog initialized" |
1477 " successfully.")) | 1469 " successfully.")) |
1478 res = dia.startProcess(cmd, args, projectPath) | 1470 res = dia.startProcess(cmd, args, projectPath) |
1479 if res: | 1471 if res: |
1480 dia.exec_() | 1472 dia.exec_() |
1481 | 1473 |
1482 langFile = self.__e5project.pdata["TRANSLATIONPATTERN"][0]\ | 1474 langFile = self.__e5project.pdata["TRANSLATIONPATTERN"][0]\ |
1487 """ | 1479 """ |
1488 Public method to compile the message catalogs. | 1480 Public method to compile the message catalogs. |
1489 | 1481 |
1490 @param filenames list of filenames (not used) | 1482 @param filenames list of filenames (not used) |
1491 """ | 1483 """ |
1492 title = self.trUtf8("Compiling message catalogs") | 1484 title = self.tr("Compiling message catalogs") |
1493 try: | 1485 try: |
1494 projectPath = self.__projectPath() | 1486 projectPath = self.__projectPath() |
1495 except PyramidNoProjectSelectedException: | 1487 except PyramidNoProjectSelectedException: |
1496 E5MessageBox.warning( | 1488 E5MessageBox.warning( |
1497 self.__ui, | 1489 self.__ui, |
1498 title, | 1490 title, |
1499 self.trUtf8('No current Pyramid project selected or no Pyramid' | 1491 self.tr('No current Pyramid project selected or no Pyramid' |
1500 ' project created yet. Aborting...')) | 1492 ' project created yet. Aborting...')) |
1501 return | 1493 return |
1502 | 1494 |
1503 cmd = self.getPythonCommand() | 1495 cmd = self.getPythonCommand() |
1504 args = [] | 1496 args = [] |
1505 args.append("setup.py") | 1497 args.append("setup.py") |
1506 args.append("compile_catalog") | 1498 args.append("compile_catalog") |
1507 | 1499 |
1508 dia = PyramidDialog( | 1500 dia = PyramidDialog( |
1509 title, | 1501 title, |
1510 msgSuccess=self.trUtf8("\nMessage catalogs compiled" | 1502 msgSuccess=self.tr("\nMessage catalogs compiled" |
1511 " successfully.")) | 1503 " successfully.")) |
1512 res = dia.startProcess(cmd, args, projectPath) | 1504 res = dia.startProcess(cmd, args, projectPath) |
1513 if res: | 1505 if res: |
1514 dia.exec_() | 1506 dia.exec_() |
1515 | 1507 |
1516 for entry in os.walk(projectPath): | 1508 for entry in os.walk(projectPath): |
1523 """ | 1515 """ |
1524 Public method to update the message catalogs. | 1516 Public method to update the message catalogs. |
1525 | 1517 |
1526 @param filenames list of file names (list of string) | 1518 @param filenames list of file names (list of string) |
1527 """ | 1519 """ |
1528 title = self.trUtf8("Compiling message catalogs") | 1520 title = self.tr("Compiling message catalogs") |
1529 try: | 1521 try: |
1530 projectPath = self.__projectPath() | 1522 projectPath = self.__projectPath() |
1531 except PyramidNoProjectSelectedException: | 1523 except PyramidNoProjectSelectedException: |
1532 E5MessageBox.warning( | 1524 E5MessageBox.warning( |
1533 self.__ui, | 1525 self.__ui, |
1534 title, | 1526 title, |
1535 self.trUtf8('No current Pyramid project selected or no Pyramid' | 1527 self.tr('No current Pyramid project selected or no Pyramid' |
1536 ' project created yet. Aborting...')) | 1528 ' project created yet. Aborting...')) |
1537 return | 1529 return |
1538 | 1530 |
1539 argsLists = [] | 1531 argsLists = [] |
1540 | 1532 |
1541 for filename in self.__normalizeList( | 1533 for filename in self.__normalizeList( |
1552 | 1544 |
1553 if len(argsLists) == 0: | 1545 if len(argsLists) == 0: |
1554 E5MessageBox.warning( | 1546 E5MessageBox.warning( |
1555 self.__ui, | 1547 self.__ui, |
1556 title, | 1548 title, |
1557 self.trUtf8('No locales detected. Aborting...')) | 1549 self.tr('No locales detected. Aborting...')) |
1558 return | 1550 return |
1559 | 1551 |
1560 dia = PyramidDialog( | 1552 dia = PyramidDialog( |
1561 title, | 1553 title, |
1562 msgSuccess=self.trUtf8("\nMessage catalogs compiled" | 1554 msgSuccess=self.tr("\nMessage catalogs compiled" |
1563 " successfully.")) | 1555 " successfully.")) |
1564 res = dia.startBatchProcesses(argsLists, projectPath) | 1556 res = dia.startBatchProcesses(argsLists, projectPath) |
1565 if res: | 1557 if res: |
1566 dia.exec_() | 1558 dia.exec_() |
1567 | 1559 |
1568 for entry in os.walk(self.__sitePath()): | 1560 for entry in os.walk(self.__sitePath()): |
1575 """ | 1567 """ |
1576 Public method to update the message catalogs. | 1568 Public method to update the message catalogs. |
1577 | 1569 |
1578 @param filenames list of filenames (not used) | 1570 @param filenames list of filenames (not used) |
1579 """ | 1571 """ |
1580 title = self.trUtf8("Updating message catalogs") | 1572 title = self.tr("Updating message catalogs") |
1581 try: | 1573 try: |
1582 projectPath = self.__projectPath() | 1574 projectPath = self.__projectPath() |
1583 except PyramidNoProjectSelectedException: | 1575 except PyramidNoProjectSelectedException: |
1584 E5MessageBox.warning( | 1576 E5MessageBox.warning( |
1585 self.__ui, | 1577 self.__ui, |
1586 title, | 1578 title, |
1587 self.trUtf8('No current Pyramid project selected or no Pyramid' | 1579 self.tr('No current Pyramid project selected or no Pyramid' |
1588 ' project created yet. Aborting...')) | 1580 ' project created yet. Aborting...')) |
1589 return | 1581 return |
1590 | 1582 |
1591 cmd = self.getPythonCommand() | 1583 cmd = self.getPythonCommand() |
1592 args = [] | 1584 args = [] |
1593 args.append("setup.py") | 1585 args.append("setup.py") |
1594 args.append("update_catalog") | 1586 args.append("update_catalog") |
1595 | 1587 |
1596 dia = PyramidDialog( | 1588 dia = PyramidDialog( |
1597 title, | 1589 title, |
1598 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) | 1590 msgSuccess=self.tr("\nMessage catalogs updated successfully.")) |
1599 res = dia.startProcess(cmd, args, projectPath) | 1591 res = dia.startProcess(cmd, args, projectPath) |
1600 if res: | 1592 if res: |
1601 dia.exec_() | 1593 dia.exec_() |
1602 | 1594 |
1603 def updateSelectedCatalogs(self, filenames): | 1595 def updateSelectedCatalogs(self, filenames): |
1604 """ | 1596 """ |
1605 Public method to update the message catalogs. | 1597 Public method to update the message catalogs. |
1606 | 1598 |
1607 @param filenames list of filenames | 1599 @param filenames list of filenames |
1608 """ | 1600 """ |
1609 title = self.trUtf8("Updating message catalogs") | 1601 title = self.tr("Updating message catalogs") |
1610 try: | 1602 try: |
1611 projectPath = self.__projectPath() | 1603 projectPath = self.__projectPath() |
1612 except PyramidNoProjectSelectedException: | 1604 except PyramidNoProjectSelectedException: |
1613 E5MessageBox.warning( | 1605 E5MessageBox.warning( |
1614 self.__ui, | 1606 self.__ui, |
1615 title, | 1607 title, |
1616 self.trUtf8('No current Pyramid project selected or no Pyramid' | 1608 self.tr('No current Pyramid project selected or no Pyramid' |
1617 ' project created yet. Aborting...')) | 1609 ' project created yet. Aborting...')) |
1618 return | 1610 return |
1619 | 1611 |
1620 argsLists = [] | 1612 argsLists = [] |
1621 | 1613 |
1622 for filename in self.__normalizeList( | 1614 for filename in self.__normalizeList( |
1633 | 1625 |
1634 if len(argsLists) == 0: | 1626 if len(argsLists) == 0: |
1635 E5MessageBox.warning( | 1627 E5MessageBox.warning( |
1636 self.__ui, | 1628 self.__ui, |
1637 title, | 1629 title, |
1638 self.trUtf8('No locales detected. Aborting...')) | 1630 self.tr('No locales detected. Aborting...')) |
1639 return | 1631 return |
1640 | 1632 |
1641 dia = PyramidDialog( | 1633 dia = PyramidDialog( |
1642 title, | 1634 title, |
1643 msgSuccess=self.trUtf8("\nMessage catalogs updated successfully.")) | 1635 msgSuccess=self.tr("\nMessage catalogs updated successfully.")) |
1644 res = dia.startBatchProcesses(argsLists, projectPath) | 1636 res = dia.startBatchProcesses(argsLists, projectPath) |
1645 if res: | 1637 if res: |
1646 dia.exec_() | 1638 dia.exec_() |
1647 | 1639 |
1648 def openPOEditor(self, poFile): | 1640 def openPOEditor(self, poFile): |
1659 wd = "" | 1651 wd = "" |
1660 started, pid = QProcess.startDetached(editor, [poFile], wd) | 1652 started, pid = QProcess.startDetached(editor, [poFile], wd) |
1661 if not started: | 1653 if not started: |
1662 E5MessageBox.critical( | 1654 E5MessageBox.critical( |
1663 None, | 1655 None, |
1664 self.trUtf8('Process Generation Error'), | 1656 self.tr('Process Generation Error'), |
1665 self.trUtf8('The translations editor process ({0}) could' | 1657 self.tr('The translations editor process ({0}) could' |
1666 ' not be started.').format( | 1658 ' not be started.').format( |
1667 os.path.basename(editor))) | 1659 os.path.basename(editor))) |