Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py

changeset 3034
7ce719013078
parent 3022
57179e4cdadd
child 3036
30c81c9e88b8
equal deleted inserted replaced
3033:58fe260e7469 3034:7ce719013078
346 for filter in filterList: 346 for filter in filterList:
347 files = \ 347 files = \
348 [f for f in files 348 [f for f in files
349 if not fnmatch.fnmatch(f, filter.strip())] 349 if not fnmatch.fnmatch(f, filter.strip())]
350 350
351 py3files = [f for f in files \ 351 py3files = [f for f in files
352 if f.endswith( 352 if f.endswith(
353 tuple(Preferences.getPython("Python3Extensions")))] 353 tuple(Preferences.getPython("Python3Extensions")))]
354 py2files = [f for f in files \ 354 py2files = [f for f in files
355 if f.endswith( 355 if f.endswith(
356 tuple(Preferences.getPython("PythonExtensions")))] 356 tuple(Preferences.getPython("PythonExtensions")))]
357 357
358 if len(py3files) + len(py2files) > 0: 358 if len(py3files) + len(py2files) > 0:
359 self.checkProgress.setMaximum(len(py3files) + len(py2files)) 359 self.checkProgress.setMaximum(len(py3files) + len(py2files))
396 source = source.splitlines(True) 396 source = source.splitlines(True)
397 except (UnicodeError, IOError) as msg: 397 except (UnicodeError, IOError) as msg:
398 self.noResults = False 398 self.noResults = False
399 self.__createResultItem( 399 self.__createResultItem(
400 file, "1", "1", 400 file, "1", "1",
401 self.trUtf8("Error: {0}").format(str(msg))\ 401 self.trUtf8("Error: {0}").format(str(msg))
402 .rstrip()[1:-1], False, False) 402 .rstrip()[1:-1], False, False)
403 progress += 1 403 progress += 1
404 continue 404 continue
405 405
406 stats = {} 406 stats = {}
414 else: 414 else:
415 fixer = None 415 fixer = None
416 if ("FileType" in flags and 416 if ("FileType" in flags and
417 flags["FileType"] in ["Python", "Python2"]) or \ 417 flags["FileType"] in ["Python", "Python2"]) or \
418 file in py2files or \ 418 file in py2files or \
419 (ext in [".py", ".pyw"] and \ 419 (ext in [".py", ".pyw"] and
420 Preferences.getProject("DeterminePyFromProject") and \ 420 Preferences.getProject("DeterminePyFromProject") and
421 self.__project.isOpen() and \ 421 self.__project.isOpen() and
422 self.__project.isProjectFile(file) and \ 422 self.__project.isProjectFile(file) and
423 self.__project.getProjectLanguage() in ["Python", 423 self.__project.getProjectLanguage() in ["Python",
424 "Python2"]): 424 "Python2"]):
425 from .CodeStyleChecker import CodeStyleCheckerPy2 425 from .CodeStyleChecker import CodeStyleCheckerPy2
426 report = CodeStyleCheckerPy2( 426 report = CodeStyleCheckerPy2(
427 file, [], 427 file, [],
434 ) 434 )
435 errors = report.errors[:] 435 errors = report.errors[:]
436 stats.update(report.counters) 436 stats.update(report.counters)
437 else: 437 else:
438 if includeMessages: 438 if includeMessages:
439 select = [s.strip() for s in 439 select = [s.strip() for s in
440 includeMessages.split(',') if s.strip()] 440 includeMessages.split(',') if s.strip()]
441 else: 441 else:
442 select = [] 442 select = []
443 if excludeMessages: 443 if excludeMessages:
444 ignore = [i.strip() for i in 444 ignore = [i.strip() for i in
445 excludeMessages.split(',') if i.strip()] 445 excludeMessages.split(',') if i.strip()]
446 else: 446 else:
447 ignore = [] 447 ignore = []
448 448
449 # check coding style 449 # check coding style
823 if filename not in fixesDict: 823 if filename not in fixesDict:
824 fixesDict[filename] = [] 824 fixesDict[filename] = []
825 fixesDict[filename].append(( 825 fixesDict[filename].append((
826 (itm.data(0, self.lineRole), 826 (itm.data(0, self.lineRole),
827 itm.data(0, self.positionRole), 827 itm.data(0, self.positionRole),
828 "{0} {1}".format(itm.data(0, self.codeRole), 828 "{0} {1}".format(itm.data(0, self.codeRole),
829 itm.data(0, self.messageRole))), 829 itm.data(0, self.messageRole))),
830 itm 830 itm
831 )) 831 ))
832 832
833 # extract the configuration values 833 # extract the configuration values

eric ide

mercurial