Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: utils/run_pylint.py

Issue 6124004: Revert "Merge remote branch 'cros/upstream' into autotest-rebase" (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/external_packages.py ('k') | utils/site_test_importer_attributes.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python -u 1 #!/usr/bin/python -u
2 2
3 import os, sys, fnmatch 3 import os, sys, fnmatch
4 import common 4 import common
5 5
6 # do a basic check to see if pylint is even installed 6 # do a basic check to see if pylint is even installed
7 try: 7 try:
8 import pylint 8 import pylint
9 from pylint.__pkginfo__ import version as pylint_version
10 except ImportError: 9 except ImportError:
11 print "Unable to import pylint, it may need to be installed" 10 print "Unable to import pylint, it may need to be installed"
12 sys.exit(1) 11 sys.exit(1)
13 12
14 major, minor, release = pylint_version.split('.')
15 pylint_version = float("%s.%s" % (major, minor))
16 pylintrc_path = os.path.expanduser('~/.pylintrc') 13 pylintrc_path = os.path.expanduser('~/.pylintrc')
17 if not os.path.exists(pylintrc_path): 14 if not os.path.exists(pylintrc_path):
18 open(pylintrc_path, 'w').close() 15 open(pylintrc_path, 'w').close()
19 16
20 17
21 # patch up the logilab module lookup tools to understand autotest_lib.* trash 18 # patch up the logilab module lookup tools to understand autotest_lib.* trash
22 import logilab.common.modutils 19 import logilab.common.modutils
23 _ffm = logilab.common.modutils.file_from_modpath 20 _ffm = logilab.common.modutils.file_from_modpath
24 def file_from_modpath(modpath, path=None, context_file=None): 21 def file_from_modpath(modpath, path=None, context_file=None):
25 if modpath[0] == "autotest_lib": 22 if modpath[0] == "autotest_lib":
(...skipping 24 matching lines...) Expand all
50 imports.ImportsChecker = CustomImportsChecker 47 imports.ImportsChecker = CustomImportsChecker
51 48
52 # some files make pylint blow up, so make sure we ignore them 49 # some files make pylint blow up, so make sure we ignore them
53 blacklist = ['/contrib/*', '/frontend/afe/management.py'] 50 blacklist = ['/contrib/*', '/frontend/afe/management.py']
54 51
55 # only show errors 52 # only show errors
56 # there are two major sources of E1101/E1103 false positives: 53 # there are two major sources of E1101/E1103 false positives:
57 # * common_lib.enum.Enum objects 54 # * common_lib.enum.Enum objects
58 # * DB model objects (scheduler models are the worst, but Django models also 55 # * DB model objects (scheduler models are the worst, but Django models also
59 # generate some errors) 56 # generate some errors)
60 if pylint_version >= 0.21: 57 pylint_base_opts = ['--disable-msg-cat=warning,refactor,convention',
61 pylint_base_opts = ['--disable=W,R,C,E1101,E1103'] 58 '--disable-msg=E1101,E1103',
62 else: 59 '--reports=no',
63 pylint_base_opts = ['--disable-msg-cat=warning,refactor,convention', 60 '--include-ids=y']
64 '--disable-msg=E1101,E1103']
65 pylint_base_opts += ['--reports=no',
66 '--include-ids=y']
67 61
68 file_list = sys.argv[1:] 62 file_list = sys.argv[1:]
69 if '--' in file_list: 63 if '--' in file_list:
70 index = file_list.index('--') 64 index = file_list.index('--')
71 pylint_base_opts.extend(file_list[index+1:]) 65 pylint_base_opts.extend(file_list[index+1:])
72 file_list = file_list[:index] 66 file_list = file_list[:index]
73 67
74 68
75 def check_file(file_path): 69 def check_file(file_path):
76 if not file_path.endswith('.py'): 70 if not file_path.endswith('.py'):
(...skipping 15 matching lines...) Expand all
92 86
93 87
94 if len(file_list) > 0: 88 if len(file_list) > 0:
95 for path in file_list: 89 for path in file_list:
96 if os.path.isdir(path): 90 if os.path.isdir(path):
97 check_dir(path) 91 check_dir(path)
98 else: 92 else:
99 check_file(path) 93 check_file(path)
100 else: 94 else:
101 check_dir('.') 95 check_dir('.')
OLDNEW
« no previous file with comments | « utils/external_packages.py ('k') | utils/site_test_importer_attributes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698