Plugins/CheckerPlugins/Pep8/Pep8Dialog.py

changeset 843
522c8befcf49
parent 832
eb5ff61f927b
child 847
cc18fbcde9fc
equal deleted inserted replaced
842:984b5535cd26 843:522c8befcf49
16 16
17 from . import pep8 17 from . import pep8
18 18
19 from E5Gui.E5Application import e5App 19 from E5Gui.E5Application import e5App
20 20
21 from .Pep8Checker import Pep8Checker 21 from .Pep8Checker import Pep8Checker, Pep8Py2Checker
22 from .Pep8CodeSelectionDialog import Pep8CodeSelectionDialog 22 from .Pep8CodeSelectionDialog import Pep8CodeSelectionDialog
23 23
24 from .Ui_Pep8Dialog import Ui_Pep8Dialog 24 from .Ui_Pep8Dialog import Ui_Pep8Dialog
25 25
26 import UI.PixmapCache 26 import UI.PixmapCache
171 elif os.path.isdir(fn): 171 elif os.path.isdir(fn):
172 files = [] 172 files = []
173 for ext in Preferences.getPython("Python3Extensions"): 173 for ext in Preferences.getPython("Python3Extensions"):
174 files.extend( 174 files.extend(
175 Utilities.direntries(fn, 1, '*{0}'.format(ext), 0)) 175 Utilities.direntries(fn, 1, '*{0}'.format(ext), 0))
176 ## for ext in Preferences.getPython("PythonExtensions"): 176 for ext in Preferences.getPython("PythonExtensions"):
177 ## files.extend( 177 files.extend(
178 ## Utilities.direntries(fn, 1, '*{0}'.format(ext), 0)) 178 Utilities.direntries(fn, 1, '*{0}'.format(ext), 0))
179 else: 179 else:
180 files = [fn] 180 files = [fn]
181 181
182 # filter the list depending on the filter string 182 # filter the list depending on the filter string
183 if files: 183 if files:
190 if not fnmatch.fnmatch(f, filter.strip())] 190 if not fnmatch.fnmatch(f, filter.strip())]
191 191
192 py3files = [f for f in files \ 192 py3files = [f for f in files \
193 if f.endswith( 193 if f.endswith(
194 tuple(Preferences.getPython("Python3Extensions")))] 194 tuple(Preferences.getPython("Python3Extensions")))]
195 py2files = [] 195 py2files = [f for f in files \
196 ## py2files = [f for f in files \ 196 if f.endswith(
197 ## if f.endswith( 197 tuple(Preferences.getPython("PythonExtensions")))]
198 ## tuple(Preferences.getPython("PythonExtensions")))]
199 198
200 if (codestring and len(py3files) == 1) or \ 199 if (codestring and len(py3files) == 1) or \
201 (codestring and len(py2files) == 1) or \ 200 (codestring and len(py2files) == 1) or \
202 (not codestring and len(py3files) + len(py2files) > 0): 201 (not codestring and len(py3files) + len(py2files) > 0):
203 self.checkProgress.setMaximum(len(py3files) + len(py2files)) 202 self.checkProgress.setMaximum(len(py3files) + len(py2files))
245 Preferences.getProject("DeterminePyFromProject") and \ 244 Preferences.getProject("DeterminePyFromProject") and \
246 self.__project.isOpen() and \ 245 self.__project.isOpen() and \
247 self.__project.isProjectFile(file) and \ 246 self.__project.isProjectFile(file) and \
248 self.__project.getProjectLanguage() in ["Python", 247 self.__project.getProjectLanguage() in ["Python",
249 "Python2"]): 248 "Python2"]):
250 # TODO: include PEP 8 check for python 2 249 checker = Pep8Py2Checker(file, [],
251 pass 250 repeat = repeatMessages,
251 select = includeMessages,
252 ignore = excludeMessages)
253 checker.messages.sort(key = lambda a: a[1])
254 for message in checker.messages:
255 fname, lineno, position, text = message
256 if not source[lineno - 1].strip()\
257 .endswith("__IGNORE_WARNING__"):
258 self.noResults = False
259 self.__createResultItem(
260 fname, lineno, position, text)
252 else: 261 else:
253 checker = Pep8Checker(file, source, 262 checker = Pep8Checker(file, source,
254 repeat = repeatMessages, 263 repeat = repeatMessages,
255 select = includeMessages, 264 select = includeMessages,
256 ignore = excludeMessages) 265 ignore = excludeMessages)

eric ide

mercurial