blob: f2d868de429fa2b59c2f219eab6be6ace66cef63 [file] [log] [blame]
Mike Frysinger53297792019-08-20 21:32:33 +00001#!/usr/bin/env python
2# Copyright 2019 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6"""Chromium wrapper for pylint for passing args via stdin.
7
8This will be executed by vpython with the right pylint versions.
9"""
10
11from __future__ import print_function
12
13import os
14import sys
15
16from pylint import lint
17
18
19HERE = os.path.dirname(os.path.abspath(__file__))
20PYLINT = os.path.join(HERE, 'pylint_main.py')
21RC_FILE = os.path.join(HERE, 'pylintrc')
22
23ARGS_ON_STDIN = '--args-on-stdin'
24
25
26def main(argv):
27 """Our main wrapper."""
28 # Add support for a custom mode where arguments are fed line by line on
29 # stdin. This allows us to get around command line length limitations.
30 if ARGS_ON_STDIN in argv:
31 argv = [x for x in argv if x != ARGS_ON_STDIN]
32 argv.extend(x.strip() for x in sys.stdin)
33
34 # We prepend the command-line with the depot_tools rcfile. If another rcfile
35 # is to be used, passing --rcfile a second time on the command-line will work
36 # fine.
37 if os.path.isfile(RC_FILE):
38 # The file can be removed to test 'normal' pylint behavior.
39 argv.insert(0, '--rcfile=%s' % RC_FILE)
40
41 lint.Run(argv)
42
43
44if __name__ == '__main__':
45 sys.exit(main(sys.argv[1:]))