Plugins/CheckerPlugins/Pep8/Pep8Dialog.py

changeset 2864
d973dab8b715
parent 2863
62171fa4a6a4
child 2866
c77e08c38a5c
equal deleted inserted replaced
2863:62171fa4a6a4 2864:d973dab8b715
335 self.__project.isOpen() and \ 335 self.__project.isOpen() and \
336 self.__project.isProjectFile(file) and \ 336 self.__project.isProjectFile(file) and \
337 self.__project.getProjectLanguage() in ["Python", 337 self.__project.getProjectLanguage() in ["Python",
338 "Python2"]): 338 "Python2"]):
339 from .Pep8Checker import Pep8Py2Checker 339 from .Pep8Checker import Pep8Py2Checker
340 checker = Pep8Py2Checker(file, [], 340 report = Pep8Py2Checker(file, [],
341 repeat=repeatMessages, 341 repeat=repeatMessages,
342 select=includeMessages, 342 select=includeMessages,
343 ignore=excludeMessages) 343 ignore=excludeMessages,
344 checker.messages.sort(key=lambda a: a[1]) 344 max_line_length=79, # TODO: make configurable
345 messages = checker.messages 345 hang_closing=False, # TODO: make configurable
346 )
347 report.errors.sort(key=lambda a: a[1])
346 else: 348 else:
347 checker = None # TODO: remove when Py2 is done
348 if includeMessages: 349 if includeMessages:
349 select = [s.strip() for s in includeMessages.split(',') 350 select = [s.strip() for s in includeMessages.split(',')
350 if s.strip()] 351 if s.strip()]
351 else: 352 else:
352 select = [] 353 select = []
359 reporter=Pep8Report, 360 reporter=Pep8Report,
360 repeat=repeatMessages, 361 repeat=repeatMessages,
361 select=select, 362 select=select,
362 ignore=ignore, 363 ignore=ignore,
363 max_line_length=79, # TODO: make configurable 364 max_line_length=79, # TODO: make configurable
365 hang_closing=False, # TODO: make configurable
364 ) 366 )
365 report = styleGuide.check_files([file]) 367 report = styleGuide.check_files([file])
366 report.errors.sort(key=lambda a: a[1]) 368 report.errors.sort(key=lambda a: a[1])
367 messages = report.errors 369 for error in report.errors:
368 for message in messages: 370 fname, lineno, position, text = error
369 fname, lineno, position, text = message
370 if lineno > len(source): 371 if lineno > len(source):
371 lineno = len(source) 372 lineno = len(source)
372 if "__IGNORE_WARNING__" not in Utilities.extractLineFlags( 373 if "__IGNORE_WARNING__" not in Utilities.extractLineFlags(
373 source[lineno - 1].strip()): 374 source[lineno - 1].strip()):
374 self.noResults = False 375 self.noResults = False
379 text += "\n" + \ 380 text += "\n" + \
380 self.trUtf8("Fix: {0}").format(msg) 381 self.trUtf8("Fix: {0}").format(msg)
381 self.__createResultItem( 382 self.__createResultItem(
382 fname, lineno, position, text, fixed) 383 fname, lineno, position, text, fixed)
383 fixer and fixer.saveFile(encoding) 384 fixer and fixer.saveFile(encoding)
384 if checker: 385 self.__updateStatistics(report.counters, fixer)
385 # TODO: remove when Py2 is done
386 self.__updateStatistics(checker.statistics, fixer)
387 else:
388 self.__updateStatistics(report.counters, fixer)
389 progress += 1 386 progress += 1
390 finally: 387 finally:
391 # reenable updates of the list 388 # reenable updates of the list
392 self.resultList.setSortingEnabled(True) 389 self.resultList.setSortingEnabled(True)
393 self.resultList.setUpdatesEnabled(True) 390 self.resultList.setUpdatesEnabled(True)

eric ide

mercurial