From 3407103d2c480e29f6c10a92cafd2f2871d1a669 Mon Sep 17 00:00:00 2001 From: "szager@chromium.org" Date: Tue, 18 Mar 2014 17:23:48 +0000 Subject: [PATCH] Presubmit check improvements. - Don't pylint files in .gitignore or .git/info/excludes - Print full path to modules in pylint. BUG= Review URL: https://codereview.chromium.org/202773002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@257672 0039d316-1c4b-4281-b951-d872f2087c98 --- PRESUBMIT.py | 13 +++++++++++++ third_party/pylint/reporters/text.py | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index a56b4834a..767eac6e7 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -8,6 +8,9 @@ See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for details on the presubmit API built into depot_tools. """ +import fnmatch +import os + def CommonChecks(input_api, output_api, tests_to_black_list): results = [] @@ -19,6 +22,16 @@ def CommonChecks(input_api, output_api, tests_to_black_list): r'^site-packages-py[0-9]\.[0-9][\/\\].+', r'^svn_bin[\/\\].+', r'^testing_support[\/\\]_rietveld[\/\\].+'] + if os.path.exists('.gitignore'): + with open('.gitignore') as fh: + lines = [l.strip() for l in fh.readlines()] + black_list.extend([fnmatch.translate(l) for l in lines if + l and not l.startswith('#')]) + if os.path.exists('.git/info/exclude'): + with open('.git/info/exclude') as fh: + lines = [l.strip() for l in fh.readlines()] + black_list.extend([fnmatch.translate(l) for l in lines if + l and not l.startswith('#')]) disabled_warnings = [ 'R0401', # Cyclic import 'W0613', # Unused argument diff --git a/third_party/pylint/reporters/text.py b/third_party/pylint/reporters/text.py index 269a519fe..032df6b16 100644 --- a/third_party/pylint/reporters/text.py +++ b/third_party/pylint/reporters/text.py @@ -47,10 +47,10 @@ class TextReporter(BaseReporter): def add_message(self, msg_id, location, msg): """manage message of different type and in the context of path""" - module, obj, line, col_offset = location[1:] + path, module, obj, line, col_offset = location if module not in self._modules: if module: - self.writeln('************* Module %s' % module) + self.writeln('************* Module %s' % (path if path else module)) self._modules[module] = 1 else: self.writeln('************* %s' % module)