OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Enables directory-specific presubmit checks to run at upload and/or commit. | 6 """Enables directory-specific presubmit checks to run at upload and/or commit. |
7 """ | 7 """ |
8 | 8 |
9 __version__ = '1.8.0' | 9 __version__ = '1.8.0' |
10 | 10 |
11 # TODO(joi) Add caching where appropriate/needed. The API is designed to allow | 11 # TODO(joi) Add caching where appropriate/needed. The API is designed to allow |
12 # caching (between all different invocations of presubmit scripts for a given | 12 # caching (between all different invocations of presubmit scripts for a given |
13 # change). We should add it as our presubmit scripts start feeling slow. | 13 # change). We should add it as our presubmit scripts start feeling slow. |
14 | 14 |
15 import cpplint | 15 import cpplint |
16 import cPickle # Exposed through the API. | 16 import cPickle # Exposed through the API. |
17 import cStringIO # Exposed through the API. | 17 import cStringIO # Exposed through the API. |
18 import contextlib | 18 import contextlib |
19 import fnmatch | 19 import fnmatch # Exposed through the API. |
20 import glob | 20 import glob |
21 import inspect | 21 import inspect |
22 import itertools | 22 import itertools |
23 import json # Exposed through the API. | 23 import json # Exposed through the API. |
24 import logging | 24 import logging |
25 import marshal # Exposed through the API. | 25 import marshal # Exposed through the API. |
26 import multiprocessing | 26 import multiprocessing |
27 import optparse | 27 import optparse |
28 import os # Somewhat exposed through the API. | 28 import os # Somewhat exposed through the API. |
29 import pickle # Exposed through the API. | 29 import pickle # Exposed through the API. |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 self.host_url = 'http://codereview.chromium.org' | 341 self.host_url = 'http://codereview.chromium.org' |
342 if self.rietveld: | 342 if self.rietveld: |
343 self.host_url = self.rietveld.url | 343 self.host_url = self.rietveld.url |
344 | 344 |
345 # We expose various modules and functions as attributes of the input_api | 345 # We expose various modules and functions as attributes of the input_api |
346 # so that presubmit scripts don't have to import them. | 346 # so that presubmit scripts don't have to import them. |
347 self.basename = os.path.basename | 347 self.basename = os.path.basename |
348 self.cPickle = cPickle | 348 self.cPickle = cPickle |
349 self.cpplint = cpplint | 349 self.cpplint = cpplint |
350 self.cStringIO = cStringIO | 350 self.cStringIO = cStringIO |
| 351 self.fnmatch = fnmatch |
351 self.glob = glob.glob | 352 self.glob = glob.glob |
352 self.json = json | 353 self.json = json |
353 self.logging = logging.getLogger('PRESUBMIT') | 354 self.logging = logging.getLogger('PRESUBMIT') |
354 self.os_listdir = os.listdir | 355 self.os_listdir = os.listdir |
355 self.os_walk = os.walk | 356 self.os_walk = os.walk |
356 self.os_path = os.path | 357 self.os_path = os.path |
357 self.os_stat = os.stat | 358 self.os_stat = os.stat |
358 self.pickle = pickle | 359 self.pickle = pickle |
359 self.marshal = marshal | 360 self.marshal = marshal |
360 self.re = re | 361 self.re = re |
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 return 2 | 1823 return 2 |
1823 | 1824 |
1824 | 1825 |
1825 if __name__ == '__main__': | 1826 if __name__ == '__main__': |
1826 fix_encoding.fix_encoding() | 1827 fix_encoding.fix_encoding() |
1827 try: | 1828 try: |
1828 sys.exit(main()) | 1829 sys.exit(main()) |
1829 except KeyboardInterrupt: | 1830 except KeyboardInterrupt: |
1830 sys.stderr.write('interrupted\n') | 1831 sys.stderr.write('interrupted\n') |
1831 sys.exit(1) | 1832 sys.exit(1) |
OLD | NEW |