PRESUBMIT.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Copyright (c) 2012 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. """Presubmit script for Chromium UI resources.
  5. See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
  6. for more details about the presubmit API built into depot_tools, and see
  7. https://chromium.googlesource.com/chromium/src/+/main/styleguide/web/web.md
  8. for the rules we're checking against here.
  9. """
  10. USE_PYTHON3 = True
  11. def CheckChangeOnUpload(input_api, output_api):
  12. return _CommonChecks(input_api, output_api)
  13. def CheckChangeOnCommit(input_api, output_api):
  14. return _CommonChecks(input_api, output_api)
  15. def _CommonChecks(input_api, output_api):
  16. """Checks common to both upload and commit."""
  17. results = []
  18. resources = input_api.PresubmitLocalPath()
  19. # List of paths with their associated scale factor. This is used to verify
  20. # that the images modified in one are the correct scale of the other.
  21. path_scales = [
  22. [(100, 'default_100_percent/'), (200, 'default_200_percent/')],
  23. ]
  24. import sys
  25. old_path = sys.path
  26. try:
  27. sys.path = [resources] + old_path
  28. from resource_check import resource_scale_factors
  29. for paths in path_scales:
  30. results.extend(resource_scale_factors.ResourceScaleFactors(
  31. input_api, output_api, paths).RunChecks())
  32. finally:
  33. sys.path = old_path
  34. return results