Updated drag and drop thumbnails.
[chromium-blink-merge.git] / chrome / browser / resources / PRESUBMIT.py
blobad761dfb69de8225bd832a13b91636524268ffdd
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.
5 """Presubmit script for Chromium WebUI resources.
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl/git cl, and see
9 http://www.chromium.org/developers/web-development-style-guide for the rules
10 we're checking against here.
11 """
14 def CheckChangeOnUpload(input_api, output_api):
15 return _CommonChecks(input_api, output_api)
18 def CheckChangeOnCommit(input_api, output_api):
19 return _CommonChecks(input_api, output_api)
22 def _CommonChecks(input_api, output_api):
23 """Checks common to both upload and commit."""
24 results = []
25 resources = input_api.PresubmitLocalPath()
27 path = input_api.os_path
28 affected_files = (f.AbsoluteLocalPath() for f in input_api.AffectedFiles())
29 would_affect_tests = (
30 path.join(resources, 'PRESUBMIT.py'),
31 path.join(resources, 'test_presubmit.py'),
32 path.join(resources, 'web_dev_style', 'css_checker.py'),
33 path.join(resources, 'web_dev_style', 'js_checker.py'),
35 if any(f for f in affected_files if f in would_affect_tests):
36 tests = [path.join(resources, 'test_presubmit.py')]
37 results.extend(
38 input_api.canned_checks.RunUnitTests(input_api, output_api, tests))
40 import sys
41 old_path = sys.path
43 try:
44 sys.path = [resources] + old_path
45 from web_dev_style import css_checker, js_checker
47 def is_resource(maybe_resource):
48 f = maybe_resource.AbsoluteLocalPath()
49 return f.endswith(('.css', '.html', '.js')) and f.startswith(resources)
51 results.extend(css_checker.CSSChecker(input_api, output_api,
52 file_filter=is_resource).RunChecks())
53 results.extend(js_checker.JSChecker(input_api, output_api,
54 file_filter=is_resource).RunChecks())
55 finally:
56 sys.path = old_path
58 return results