OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 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.3.4' | 9 __version__ = '1.3.4' |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 import subprocess # Exposed through the API. | 27 import subprocess # Exposed through the API. |
28 import sys # Parts exposed through API. | 28 import sys # Parts exposed through API. |
29 import tempfile # Exposed through the API. | 29 import tempfile # Exposed through the API. |
30 import time | 30 import time |
31 import traceback # Exposed through the API. | 31 import traceback # Exposed through the API. |
32 import types | 32 import types |
33 import unittest # Exposed through the API. | 33 import unittest # Exposed through the API. |
34 import urllib2 # Exposed through the API. | 34 import urllib2 # Exposed through the API. |
35 import warnings | 35 import warnings |
36 | 36 |
| 37 # json may not be available. |
| 38 try: |
| 39 import simplejson as json |
| 40 except ImportError: |
| 41 try: |
| 42 import json |
| 43 except ImportError: |
| 44 json = None |
| 45 |
37 # Local imports. | 46 # Local imports. |
38 import gcl | 47 import gcl |
39 import gclient_utils | 48 import gclient_utils |
40 import presubmit_canned_checks | 49 import presubmit_canned_checks |
41 import scm | 50 import scm |
42 | 51 |
43 | 52 |
44 # Ask for feedback only once in program lifetime. | 53 # Ask for feedback only once in program lifetime. |
45 _ASKED_FOR_FEEDBACK = False | 54 _ASKED_FOR_FEEDBACK = False |
46 | 55 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 # Version number of the presubmit_support script. | 198 # Version number of the presubmit_support script. |
190 self.version = [int(x) for x in __version__.split('.')] | 199 self.version = [int(x) for x in __version__.split('.')] |
191 self.change = change | 200 self.change = change |
192 self.is_committing = is_committing | 201 self.is_committing = is_committing |
193 | 202 |
194 # We expose various modules and functions as attributes of the input_api | 203 # We expose various modules and functions as attributes of the input_api |
195 # so that presubmit scripts don't have to import them. | 204 # so that presubmit scripts don't have to import them. |
196 self.basename = os.path.basename | 205 self.basename = os.path.basename |
197 self.cPickle = cPickle | 206 self.cPickle = cPickle |
198 self.cStringIO = cStringIO | 207 self.cStringIO = cStringIO |
| 208 self.json = json |
199 self.os_path = os.path | 209 self.os_path = os.path |
200 self.pickle = pickle | 210 self.pickle = pickle |
201 self.marshal = marshal | 211 self.marshal = marshal |
202 self.re = re | 212 self.re = re |
203 self.subprocess = subprocess | 213 self.subprocess = subprocess |
204 self.tempfile = tempfile | 214 self.tempfile = tempfile |
205 self.traceback = traceback | 215 self.traceback = traceback |
206 self.unittest = unittest | 216 self.unittest = unittest |
207 self.urllib2 = urllib2 | 217 self.urllib2 = urllib2 |
208 | 218 |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 options.commit, | 1059 options.commit, |
1050 options.verbose, | 1060 options.verbose, |
1051 sys.stdout, | 1061 sys.stdout, |
1052 sys.stdin, | 1062 sys.stdin, |
1053 options.default_presubmit, | 1063 options.default_presubmit, |
1054 options.may_prompt) | 1064 options.may_prompt) |
1055 | 1065 |
1056 | 1066 |
1057 if __name__ == '__main__': | 1067 if __name__ == '__main__': |
1058 sys.exit(Main(sys.argv)) | 1068 sys.exit(Main(sys.argv)) |
OLD | NEW |