PluginPyLint.py

changeset 46
a781953e3703
parent 44
ee702eaaefda
child 48
69c4c0e04bf6
equal deleted inserted replaced
45:0ae4a6726423 46:a781953e3703
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.0.1" 38 version = "6.1.0"
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""" \
133 import winreg 133 import winreg
134 except ImportError: 134 except ImportError:
135 import _winreg as winreg # __IGNORE_WARNING__ 135 import _winreg as winreg # __IGNORE_WARNING__
136 136
137 def getExePath(branch, access, versionStr): 137 def getExePath(branch, access, versionStr):
138 exes = []
138 try: 139 try:
139 software = winreg.OpenKey(branch, 'Software', 0, access) 140 software = winreg.OpenKey(branch, 'Software', 0, access)
140 python = winreg.OpenKey(software, 'Python', 0, access) 141 python = winreg.OpenKey(software, 'Python', 0, access)
141 pcore = winreg.OpenKey(python, 'PythonCore', 0, access) 142 pcore = winreg.OpenKey(python, 'PythonCore', 0, access)
142 version = winreg.OpenKey(pcore, versionStr, 0, access) 143 version = winreg.OpenKey(pcore, versionStr, 0, access)
143 installpath = winreg.QueryValue(version, 'InstallPath') 144 installpath = winreg.QueryValue(version, 'InstallPath')
145 # Look for the batch script variant
144 exe = os.path.join(installpath, 'Scripts', 'pylint.bat') 146 exe = os.path.join(installpath, 'Scripts', 'pylint.bat')
145 if os.access(exe, os.X_OK): 147 if os.access(exe, os.X_OK):
146 return exe 148 exes.append(exe)
147 except WindowsError: # __IGNORE_WARNING__ 149 # Look for the executable variant
148 return None 150 exe = os.path.join(installpath, 'Scripts', 'pylint.exe')
149 return None 151 if os.access(exe, os.X_OK):
152 exes.append(exe)
153 except (WindowsError, FileNotFoundError): # __IGNORE_WARNING__
154 pass
155 return exes
150 156
151 for minorVersion in minorVersions: 157 for minorVersion in minorVersions:
152 versionStr = '{0}.{1}'.format(majorVersion, minorVersion) 158 versionStr = '{0}.{1}'.format(majorVersion, minorVersion)
153 exePath = getExePath( 159 exePaths = getExePath(
154 winreg.HKEY_CURRENT_USER, 160 winreg.HKEY_CURRENT_USER,
155 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr) 161 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr)
156 162 if exePaths:
157 if exePath is not None: 163 for exePath in exePaths:
158 executables.add(exePath) 164 executables.add(exePath)
159 exePath = getExePath( 165
166 exePaths = getExePath(
160 winreg.HKEY_LOCAL_MACHINE, 167 winreg.HKEY_LOCAL_MACHINE,
161 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr) 168 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr)
169 if exePaths:
170 for exePath in exePaths:
171 executables.add(exePath)
162 172
163 # Even on Intel 64-bit machines it's 'AMD64' 173 # Even on Intel 64-bit machines it's 'AMD64'
164 if platform.machine() == 'AMD64': 174 if platform.machine() == 'AMD64':
165 if exePath is not None: 175 exePaths = getExePath(
166 executables.add(exePath)
167 exePath = getExePath(
168 winreg.HKEY_CURRENT_USER, 176 winreg.HKEY_CURRENT_USER,
169 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr) 177 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr)
178 if exePaths:
179 for exePath in exePaths:
180 executables.add(exePath)
170 181
171 if exePath is not None:
172 executables.add(exePath)
173 exePath = getExePath( 182 exePath = getExePath(
174 winreg.HKEY_LOCAL_MACHINE, 183 winreg.HKEY_LOCAL_MACHINE,
175 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr) 184 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr)
176 185 if exePaths:
177 if exePath is not None: 186 for exePath in exePaths:
178 executables.add(exePath) 187 executables.add(exePath)
179 else: 188 else:
180 # 189 #
181 # Linux, Unix ... 190 # Linux, Unix ...
182 pylintScript = 'pylint' 191 pylintScript = 'pylint'
183 scriptSuffixes = ["", 192 scriptSuffixes = ["",

eric ide

mercurial