92 |
93 |
93 def __serviceError(self, fn, msg): |
94 def __serviceError(self, fn, msg): |
94 """ |
95 """ |
95 Private slot handling service errors. |
96 Private slot handling service errors. |
96 |
97 |
97 @param fn file name (string) |
98 @param fn file name |
98 @param msg message text (string) |
99 @type str |
|
100 @param msg message text |
|
101 @type str |
99 """ |
102 """ |
100 self.error.emit(fn, msg) |
103 self.error.emit(fn, msg) |
101 |
104 |
102 def serviceErrorPy3(self, fx, lang, fn, msg): |
105 def serviceErrorPy3(self, fx, lang, fn, msg): |
103 """ |
106 """ |
104 Public slot handling service errors for Python 3. |
107 Public slot handling service errors for Python 3. |
105 |
108 |
106 @param fx service name (string) |
109 @param fx service name |
107 @param lang language (string) |
110 @type str |
108 @param fn file name (string) |
111 @param lang language |
109 @param msg message text (string) |
112 @type str |
|
113 @param fn file name |
|
114 @type str |
|
115 @param msg message text |
|
116 @type str |
110 """ |
117 """ |
111 if fx in ["style", "batch_style"] and lang == "Python3": |
118 if fx in ["style", "batch_style"] and lang == "Python3": |
112 if fx == "style": |
119 if fx == "style": |
113 self.__serviceError(fn, msg) |
120 self.__serviceError(fn, msg) |
114 else: |
121 else: |
117 |
124 |
118 def batchJobDone(self, fx, lang): |
125 def batchJobDone(self, fx, lang): |
119 """ |
126 """ |
120 Public slot handling the completion of a batch job. |
127 Public slot handling the completion of a batch job. |
121 |
128 |
122 @param fx service name (string) |
129 @param fx service name |
123 @param lang language (string) |
130 @type str |
|
131 @param lang language |
|
132 @type str |
124 """ |
133 """ |
125 if fx in ["style", "batch_style"]: |
134 if fx in ["style", "batch_style"]: |
126 if lang in self.queuedBatches: |
135 if lang in self.queuedBatches: |
127 self.queuedBatches.remove(lang) |
136 self.queuedBatches.remove(lang) |
128 # prevent sending the signal multiple times |
137 # prevent sending the signal multiple times |
242 |
251 |
243 def activate(self): |
252 def activate(self): |
244 """ |
253 """ |
245 Public method to activate this plugin. |
254 Public method to activate this plugin. |
246 |
255 |
247 @return tuple of None and activation status (boolean) |
256 @return tuple of None and activation status |
|
257 @rtype bool |
248 """ |
258 """ |
249 menu = ericApp().getObject("Project").getMenu("Checks") |
259 menu = ericApp().getObject("Project").getMenu("Checks") |
250 if menu: |
260 if menu: |
251 self.__projectAct = EricAction( |
261 self.__projectAct = EricAction( |
252 self.tr("Check Code Style"), |
262 self.tr("Check Code Style"), |
325 def __projectShowMenu(self, menuName, menu): # noqa: U100 |
335 def __projectShowMenu(self, menuName, menu): # noqa: U100 |
326 """ |
336 """ |
327 Private slot called, when the the project menu or a submenu is |
337 Private slot called, when the the project menu or a submenu is |
328 about to be shown. |
338 about to be shown. |
329 |
339 |
330 @param menuName name of the menu to be shown (string) |
340 @param menuName name of the menu to be shown |
331 @param menu reference to the menu (QMenu) |
341 @type str |
|
342 @param menu reference to the menu |
|
343 @type QMenu |
332 """ |
344 """ |
333 if menuName == "Checks" and self.__projectAct is not None: |
345 if menuName == "Checks" and self.__projectAct is not None: |
334 self.__projectAct.setEnabled( |
346 self.__projectAct.setEnabled( |
335 ericApp().getObject("Project").getProjectLanguage() |
347 ericApp().getObject("Project").getProjectLanguage() |
336 in ["Python3", "MicroPython"] |
348 in ["Python3", "MicroPython"] |
339 def __projectBrowserShowMenu(self, menuName, menu): |
351 def __projectBrowserShowMenu(self, menuName, menu): |
340 """ |
352 """ |
341 Private slot called, when the the project browser menu or a submenu is |
353 Private slot called, when the the project browser menu or a submenu is |
342 about to be shown. |
354 about to be shown. |
343 |
355 |
344 @param menuName name of the menu to be shown (string) |
356 @param menuName name of the menu to be shown |
345 @param menu reference to the menu (QMenu) |
357 @type str |
|
358 @param menu reference to the menu |
|
359 @type QMenu |
346 """ |
360 """ |
347 if menuName == "Checks" and ericApp().getObject( |
361 if menuName == "Checks" and ericApp().getObject( |
348 "Project" |
362 "Project" |
349 ).getProjectLanguage() in ["Python3", "MicroPython"]: |
363 ).getProjectLanguage() in ["Python3", "MicroPython"]: |
350 self.__projectBrowserMenu = menu |
364 self.__projectBrowserMenu = menu |
426 |
440 |
427 def __editorOpened(self, editor): |
441 def __editorOpened(self, editor): |
428 """ |
442 """ |
429 Private slot called, when a new editor was opened. |
443 Private slot called, when a new editor was opened. |
430 |
444 |
431 @param editor reference to the new editor (QScintilla.Editor) |
445 @param editor reference to the new editor |
|
446 @type Editor |
432 """ |
447 """ |
433 menu = editor.getMenu("Checks") |
448 menu = editor.getMenu("Checks") |
434 if menu is not None: |
449 if menu is not None: |
435 menu.addAction(self.__editorAct) |
450 menu.addAction(self.__editorAct) |
436 editor.showMenu.connect(self.__editorShowMenu) |
451 editor.showMenu.connect(self.__editorShowMenu) |
438 |
453 |
439 def __editorClosed(self, editor): |
454 def __editorClosed(self, editor): |
440 """ |
455 """ |
441 Private slot called, when an editor was closed. |
456 Private slot called, when an editor was closed. |
442 |
457 |
443 @param editor reference to the editor (QScintilla.Editor) |
458 @param editor reference to the editor |
|
459 @type Editor |
444 """ |
460 """ |
445 with contextlib.suppress(ValueError): |
461 with contextlib.suppress(ValueError): |
446 self.__editors.remove(editor) |
462 self.__editors.remove(editor) |
447 |
463 |
448 def __editorShowMenu(self, menuName, menu, editor): |
464 def __editorShowMenu(self, menuName, menu, editor): |
449 """ |
465 """ |
450 Private slot called, when the the editor context menu or a submenu is |
466 Private slot called, when the the editor context menu or a submenu is |
451 about to be shown. |
467 about to be shown. |
452 |
468 |
453 @param menuName name of the menu to be shown (string) |
469 @param menuName name of the menu to be shown |
454 @param menu reference to the menu (QMenu) |
470 @type str |
|
471 @param menu reference to the menu |
|
472 @type QMenu |
455 @param editor reference to the editor |
473 @param editor reference to the editor |
|
474 @type Editor |
456 """ |
475 """ |
457 if menuName == "Checks": |
476 if menuName == "Checks": |
458 if self.__editorAct not in menu.actions(): |
477 if self.__editorAct not in menu.actions(): |
459 menu.addAction(self.__editorAct) |
478 menu.addAction(self.__editorAct) |
460 self.__editorAct.setEnabled(editor.isPyFile()) |
479 self.__editorAct.setEnabled(editor.isPyFile()) |