PluginPyLint.py

branch
eric7
changeset 112
7ece4ae4b274
parent 110
f099cbc11de2
child 114
524f52c0ac34
equal deleted inserted replaced
111:08abc7df5a43 112:7ece4ae4b274
5 5
6 """ 6 """
7 Module implementing the PyLint plug-in. 7 Module implementing the PyLint plug-in.
8 """ 8 """
9 9
10 import contextlib
11 import copy
12 import os
13 import platform
10 import re 14 import re
11 import os 15
12 import copy 16 from PyQt6.QtCore import QCoreApplication, QObject, QProcess, QTranslator
13 import platform
14 import contextlib
15
16 from PyQt6.QtCore import QObject, QTranslator, QCoreApplication, QProcess
17 from PyQt6.QtWidgets import QDialog 17 from PyQt6.QtWidgets import QDialog
18 18
19 from eric7 import Preferences, Utilities 19 from eric7 import Preferences
20 from eric7.EricGui.EricAction import EricAction 20 from eric7.EricGui.EricAction import EricAction
21 from eric7.EricWidgets import EricMessageBox 21 from eric7.EricWidgets import EricMessageBox
22 from eric7.EricWidgets.EricApplication import ericApp 22 from eric7.EricWidgets.EricApplication import ericApp
23 from eric7.Project.ProjectBrowserModel import ProjectBrowserFileItem 23 from eric7.Project.ProjectBrowserModel import ProjectBrowserFileItem
24
25 try:
26 from eric7.SystemUtilities.OSUtilities import getEnvironmentEntry, isWindowsPlatform
27 except ImportError:
28 # imports for eric < 23.1
29 from eric7.Utilities import getEnvironmentEntry, isWindowsPlatform
24 30
25 # Start-of-Header 31 # Start-of-Header
26 name = "PyLint Plugin" 32 name = "PyLint Plugin"
27 author = "Detlev Offenbach <detlev@die-offenbachs.de>" 33 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
28 autoactivate = True 34 autoactivate = True
29 deactivateable = True 35 deactivateable = True
30 version = "10.1.1" 36 version = "10.2.0"
31 className = "PyLintPlugin" 37 className = "PyLintPlugin"
32 packageName = "PyLintInterface" 38 packageName = "PyLintInterface"
33 shortDescription = "Show the PyLint dialogs." 39 shortDescription = "Show the PyLint dialogs."
34 longDescription = ( 40 longDescription = (
35 """This plug-in implements the PyLint dialogs. PyLint is used to check""" 41 """This plug-in implements the PyLint dialogs. PyLint is used to check"""
113 minorVersions = range(10) 119 minorVersions = range(10)
114 else: 120 else:
115 return [] 121 return []
116 122
117 executables = set() 123 executables = set()
118 if Utilities.isWindowsPlatform(): 124 if isWindowsPlatform():
119 # 125 #
120 # Windows 126 # Windows
121 # 127 #
122 try: 128 try:
123 import winreg 129 import winreg
187 executables.add(exePath) 193 executables.add(exePath)
188 194
189 if not executables and majorVersion >= 3: 195 if not executables and majorVersion >= 3:
190 # check the PATH environment variable if nothing was found 196 # check the PATH environment variable if nothing was found
191 # Python 3 only 197 # Python 3 only
192 path = Utilities.getEnvironmentEntry("PATH") 198 path = getEnvironmentEntry("PATH")
193 if path: 199 if path:
194 dirs = path.split(os.pathsep) 200 dirs = path.split(os.pathsep)
195 for directory in dirs: 201 for directory in dirs:
196 for suffix in (".bat", ".exe"): 202 for suffix in (".bat", ".exe"):
197 exe = os.path.join(directory, "pylint" + suffix) 203 exe = os.path.join(directory, "pylint" + suffix)
208 ] 214 ]
209 for minorVersion in minorVersions: 215 for minorVersion in minorVersions:
210 scriptSuffixes.append("-python{0}.{1}".format(majorVersion, minorVersion)) 216 scriptSuffixes.append("-python{0}.{1}".format(majorVersion, minorVersion))
211 # There could be multiple pylint executables in the path 217 # There could be multiple pylint executables in the path
212 # e.g. for different python variants 218 # e.g. for different python variants
213 path = Utilities.getEnvironmentEntry("PATH") 219 path = getEnvironmentEntry("PATH")
214 # environment variable not defined 220 # environment variable not defined
215 if path is None: 221 if path is None:
216 return [] 222 return []
217 223
218 # step 1: determine possible candidates 224 # step 1: determine possible candidates

eric ide

mercurial