17 import os |
17 import os |
18 import copy |
18 import copy |
19 import platform |
19 import platform |
20 |
20 |
21 from PyQt5.QtCore import QObject, QTranslator, QCoreApplication, QProcess |
21 from PyQt5.QtCore import QObject, QTranslator, QCoreApplication, QProcess |
22 from PyQt5.QtWidgets import QDialog |
22 from PyQt5.QtWidgets import QDialog |
23 |
23 |
24 from E5Gui.E5Application import e5App |
24 from E5Gui.E5Application import e5App |
25 from E5Gui.E5Action import E5Action |
25 from E5Gui.E5Action import E5Action |
26 from E5Gui import E5MessageBox |
26 from E5Gui import E5MessageBox |
27 |
27 |
33 # Start-of-Header |
33 # Start-of-Header |
34 name = "PyLint Plugin" |
34 name = "PyLint Plugin" |
35 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
35 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
36 autoactivate = True |
36 autoactivate = True |
37 deactivateable = True |
37 deactivateable = True |
38 version = "6.1.4" |
38 version = "6.1.5" |
39 className = "PyLintPlugin" |
39 className = "PyLintPlugin" |
40 packageName = "PyLint" |
40 packageName = "PyLint" |
41 shortDescription = "Show the PyLint dialogs." |
41 shortDescription = "Show the PyLint dialogs." |
42 longDescription = """This plug-in implements the PyLint dialogs.""" \ |
42 longDescription = """This plug-in implements the PyLint dialogs.""" \ |
43 """ PyLint is used to check Python source files according to various""" \ |
43 """ PyLint is used to check Python source files according to various""" \ |
201 return [] |
201 return [] |
202 |
202 |
203 # step 1: determine possible candidates |
203 # step 1: determine possible candidates |
204 exes = [] |
204 exes = [] |
205 dirs = path.split(os.pathsep) |
205 dirs = path.split(os.pathsep) |
206 for dir in dirs: |
206 for directory in dirs: |
207 for suffix in scriptSuffixes: |
207 for suffix in scriptSuffixes: |
208 exe = os.path.join(dir, pylintScript + suffix) |
208 exe = os.path.join(directory, pylintScript + suffix) |
209 if os.access(exe, os.X_OK): |
209 if os.access(exe, os.X_OK): |
210 exes.append(exe) |
210 exes.append(exe) |
211 |
211 |
212 # step 2: determine the Python variant |
212 # step 2: determine the Python variant |
213 if Utilities.isMacPlatform(): |
213 if Utilities.isMacPlatform(): |
486 """ of the last run.</p>""" |
486 """ of the last run.</p>""" |
487 )) |
487 )) |
488 self.__projectBrowserShowAct.triggered.connect( |
488 self.__projectBrowserShowAct.triggered.connect( |
489 self.__projectBrowserPylintShow) |
489 self.__projectBrowserPylintShow) |
490 |
490 |
491 if not self.__projectBrowserAct in menu.actions(): |
491 if self.__projectBrowserAct not in menu.actions(): |
492 menu.addAction(self.__projectBrowserAct) |
492 menu.addAction(self.__projectBrowserAct) |
493 if not self.__projectBrowserShowAct in menu.actions(): |
493 if self.__projectBrowserShowAct not in menu.actions(): |
494 menu.addAction(self.__projectBrowserShowAct) |
494 menu.addAction(self.__projectBrowserShowAct) |
495 |
495 |
496 enable = e5App().getObject("ProjectBrowser")\ |
496 enable = e5App().getObject("ProjectBrowser")\ |
497 .getProjectBrowser("sources")\ |
497 .getProjectBrowser("sources")\ |
498 .getSelectedItemsCount([ProjectBrowserFileItem]) == 1 |
498 .getSelectedItemsCount([ProjectBrowserFileItem]) == 1 |
554 else: |
554 else: |
555 self.__pylintPsbDialog = dlg2 |
555 self.__pylintPsbDialog = dlg2 |
556 |
556 |
557 def __projectPylint(self): |
557 def __projectPylint(self): |
558 """ |
558 """ |
559 Public slot used to check the project files with Pylint. |
559 Private slot used to check the project files with Pylint. |
560 """ |
560 """ |
561 project = e5App().getObject("Project") |
561 project = e5App().getObject("Project") |
562 project.saveAllScripts() |
562 project.saveAllScripts() |
563 self.__pyLint(project, project.getProjectPath(), True) |
563 self.__pyLint(project, project.getProjectPath(), True) |
564 |
564 |
565 def __projectPylintShow(self): |
565 def __projectPylintShow(self): |
566 """ |
566 """ |
567 Public slot to show the PyLint dialog with the results of the last run. |
567 Private slot to show the PyLint dialog with the results of the last |
|
568 run. |
568 """ |
569 """ |
569 if self.__pylintPDialog is not None: |
570 if self.__pylintPDialog is not None: |
570 self.__pylintPDialog.show() |
571 self.__pylintPDialog.show() |
571 |
572 |
572 def __projectBrowserPylint(self): |
573 def __projectBrowserPylint(self): |
584 fn = itm.dirName() |
585 fn = itm.dirName() |
585 self.__pyLint(project, fn, False) |
586 self.__pyLint(project, fn, False) |
586 |
587 |
587 def __projectBrowserPylintShow(self): |
588 def __projectBrowserPylintShow(self): |
588 """ |
589 """ |
589 Public slot to show the PyLint dialog with the results of the last run. |
590 Private slot to show the PyLint dialog with the results of the last |
|
591 run. |
590 """ |
592 """ |
591 if self.__pylintPsbDialog is not None: |
593 if self.__pylintPsbDialog is not None: |
592 self.__pylintPsbDialog.show() |
594 self.__pylintPsbDialog.show() |
593 |
595 |
594 def __editorOpened(self, editor): |
596 def __editorOpened(self, editor): |
622 @param menuName name of the menu to be shown (string) |
624 @param menuName name of the menu to be shown (string) |
623 @param menu reference to the menu (QMenu) |
625 @param menu reference to the menu (QMenu) |
624 @param editor reference to the editor (QScintilla.Editor) |
626 @param editor reference to the editor (QScintilla.Editor) |
625 """ |
627 """ |
626 if menuName == "Checks": |
628 if menuName == "Checks": |
627 if not self.__editorAct in menu.actions(): |
629 if self.__editorAct not in menu.actions(): |
628 menu.addAction(self.__editorAct) |
630 menu.addAction(self.__editorAct) |
629 self.__editorAct.setEnabled( |
631 self.__editorAct.setEnabled( |
630 editor.isPy3File() or editor.isPy2File()) |
632 editor.isPy3File() or editor.isPy2File()) |
631 |
633 |
632 def __editorPylint(self): |
634 def __editorPylint(self): |