OLD | NEW |
| (Empty) |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 import os | |
5 import sys | |
6 | |
7 def _CommonChecks(input_api, output_api): | |
8 results = [] | |
9 # Importing ui actually brings tvcm into the path. | |
10 import ui | |
11 from tvcm import presubmit_checker | |
12 checker = presubmit_checker.PresubmitChecker(input_api, output_api) | |
13 results += checker.RunChecks() | |
14 return results | |
15 | |
16 def GetPathsToPrepend(input_api): | |
17 return [input_api.PresubmitLocalPath()] | |
18 | |
19 def RunWithPrependedPath(prepended_path, fn, *args): | |
20 old_path = sys.path | |
21 | |
22 try: | |
23 sys.path = prepended_path + old_path | |
24 return fn(*args) | |
25 finally: | |
26 sys.path = old_path | |
27 | |
28 def CheckChangeOnUpload(input_api, output_api): | |
29 def go(): | |
30 results = [] | |
31 results.extend(_CommonChecks(input_api, output_api)) | |
32 return results | |
33 return RunWithPrependedPath(GetPathsToPrepend(input_api), go) | |
34 | |
35 def CheckChangeOnCommit(input_api, output_api): | |
36 def go(): | |
37 results = [] | |
38 results.extend(_CommonChecks(input_api, output_api)) | |
39 return results | |
40 return RunWithPrependedPath(GetPathsToPrepend(input_api), go) | |
OLD | NEW |