| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 import os | 4 import os |
| 5 import sys | 5 import sys |
| 6 | 6 |
| 7 PYLINT_BLACKLIST = [] | |
| 8 PYLINT_DISABLED_WARNINGS = ['R0923', 'R0201', 'E1101'] | |
| 9 | |
| 10 def _CommonChecks(input_api, output_api): | 7 def _CommonChecks(input_api, output_api): |
| 11 results = [] | 8 results = [] |
| 12 | 9 # Importing ui actually brings tvcm into the path. |
| 13 # TODO(nduca): This should call update_docs.IsUpdateDocsNeeded(). | 10 import ui |
| 14 # Disabled due to crbug.com/255326. | |
| 15 if False: | |
| 16 update_docs_path = os.path.join( | |
| 17 input_api.PresubmitLocalPath(), 'update_docs') | |
| 18 assert os.path.exists(update_docs_path) | |
| 19 results.append(output_api.PresubmitError( | |
| 20 'Docs are stale. Please run:\n' + | |
| 21 '$ %s' % os.path.abspath(update_docs_path))) | |
| 22 | |
| 23 # Importing telemetry.web_components actually brings tvcm into the path. | |
| 24 import telemetry.web_components # pylint: disable=W0612 | |
| 25 from tvcm import presubmit_checker | 11 from tvcm import presubmit_checker |
| 26 checker = presubmit_checker.PresubmitChecker(input_api, output_api) | 12 checker = presubmit_checker.PresubmitChecker(input_api, output_api) |
| 27 results += checker.RunChecks() | 13 results += checker.RunChecks() |
| 28 | |
| 29 results.extend(input_api.canned_checks.RunPylint( | |
| 30 input_api, output_api, | |
| 31 black_list=PYLINT_BLACKLIST, | |
| 32 disabled_warnings=PYLINT_DISABLED_WARNINGS)) | |
| 33 return results | 14 return results |
| 34 | 15 |
| 35 def GetPathsToPrepend(input_api): | 16 def GetPathsToPrepend(input_api): |
| 36 return [input_api.PresubmitLocalPath()] | 17 return [input_api.PresubmitLocalPath()] |
| 37 | 18 |
| 38 def RunWithPrependedPath(prepended_path, fn, *args): | 19 def RunWithPrependedPath(prepended_path, fn, *args): |
| 39 old_path = sys.path | 20 old_path = sys.path |
| 40 | 21 |
| 41 try: | 22 try: |
| 42 sys.path = prepended_path + old_path | 23 sys.path = prepended_path + old_path |
| 43 return fn(*args) | 24 return fn(*args) |
| 44 finally: | 25 finally: |
| 45 sys.path = old_path | 26 sys.path = old_path |
| 46 | 27 |
| 47 def CheckChangeOnUpload(input_api, output_api): | 28 def CheckChangeOnUpload(input_api, output_api): |
| 48 def go(): | 29 def go(): |
| 49 results = [] | 30 results = [] |
| 50 results.extend(_CommonChecks(input_api, output_api)) | 31 results.extend(_CommonChecks(input_api, output_api)) |
| 51 return results | 32 return results |
| 52 return RunWithPrependedPath(GetPathsToPrepend(input_api), go) | 33 return RunWithPrependedPath(GetPathsToPrepend(input_api), go) |
| 53 | 34 |
| 54 def CheckChangeOnCommit(input_api, output_api): | 35 def CheckChangeOnCommit(input_api, output_api): |
| 55 def go(): | 36 def go(): |
| 56 results = [] | 37 results = [] |
| 57 results.extend(_CommonChecks(input_api, output_api)) | 38 results.extend(_CommonChecks(input_api, output_api)) |
| 58 return results | 39 return results |
| 59 return RunWithPrependedPath(GetPathsToPrepend(input_api), go) | 40 return RunWithPrependedPath(GetPathsToPrepend(input_api), go) |
| OLD | NEW |