
I also had to make svgo_presubmit compatible with python3. Bug: 1211993 Change-Id: If146ec22623b7e84645fa981ae61f4f8feb85595 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2929464 Commit-Queue: Dan H <harringtond@chromium.org> Reviewed-by: Ted Choc <tedchoc@chromium.org> Reviewed-by: Andrew Grieve <agrieve@chromium.org> Cr-Commit-Position: refs/heads/master@{#895295}
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
# Copyright 2019 The Chromium Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
USE_PYTHON3 = True
|
|
|
|
def CheckChangeOnUpload(input_api, output_api):
|
|
return _CommonChecks(input_api, output_api)
|
|
|
|
|
|
def CheckChangeOnCommit(input_api, output_api):
|
|
return _CommonChecks(input_api, output_api)
|
|
|
|
|
|
def _CheckSvgsOptimized(input_api, output_api):
|
|
results = []
|
|
try:
|
|
import sys
|
|
old_sys_path = sys.path[:]
|
|
cwd = input_api.PresubmitLocalPath()
|
|
sys.path += [input_api.os_path.join(cwd, '..', 'tools')]
|
|
from resources import svgo_presubmit
|
|
results += svgo_presubmit.CheckOptimized(input_api, output_api)
|
|
finally:
|
|
sys.path = old_sys_path
|
|
return results
|
|
|
|
|
|
def _CheckWebDevStyle(input_api, output_api):
|
|
results = []
|
|
try:
|
|
import sys
|
|
old_sys_path = sys.path[:]
|
|
cwd = input_api.PresubmitLocalPath()
|
|
sys.path += [input_api.os_path.join(cwd, '..', 'tools')]
|
|
from web_dev_style import presubmit_support
|
|
results += presubmit_support.CheckStyle(input_api, output_api)
|
|
finally:
|
|
sys.path = old_sys_path
|
|
return results
|
|
|
|
|
|
def _CommonChecks(input_api, output_api):
|
|
results = []
|
|
results += _CheckSvgsOptimized(input_api, output_api)
|
|
results += _CheckWebDevStyle(input_api, output_api)
|
|
results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api,
|
|
check_js=True)
|
|
return results
|