OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 | 4 |
5 """Presubmit script for Chromium WebUI resources. | 5 """Presubmit script for Chromium WebUI resources. |
6 | 6 |
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 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 | 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 | 9 http://www.chromium.org/developers/web-development-style-guide for the rules |
10 we're checking against here. | 10 we're checking against here. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 sys.path = [resources] + old_path | 44 sys.path = [resources] + old_path |
45 from web_dev_style import css_checker, js_checker | 45 from web_dev_style import css_checker, js_checker |
46 | 46 |
47 def _html_css_js_resource(p): | 47 def _html_css_js_resource(p): |
48 return p.endswith(('.html', '.css', '.js')) and p.startswith(resources) | 48 return p.endswith(('.html', '.css', '.js')) and p.startswith(resources) |
49 | 49 |
50 def is_resource(maybe_resource): | 50 def is_resource(maybe_resource): |
51 return _html_css_js_resource(maybe_resource.AbsoluteLocalPath()) | 51 return _html_css_js_resource(maybe_resource.AbsoluteLocalPath()) |
52 | 52 |
53 # TODO(samarth): remove this exception <http://crbug.com/222642>. | 53 # TODO(samarth): remove this exception <http://crbug.com/222642>. |
54 instant_path = path.join(resources, 'local_omnibox_popup') | 54 instant_path = path.join(resources, 'local_ntp') |
55 def is_resource_no_instant(maybe_resource): | 55 def is_resource_no_instant(maybe_resource): |
56 f = maybe_resource.AbsoluteLocalPath() | 56 f = maybe_resource.AbsoluteLocalPath() |
57 return _html_css_js_resource(f) and not f.startswith(instant_path) | 57 return _html_css_js_resource(f) and not f.startswith(instant_path) |
58 | 58 |
59 results.extend(css_checker.CSSChecker( | 59 results.extend(css_checker.CSSChecker( |
60 input_api, output_api, file_filter=is_resource_no_instant).RunChecks()) | 60 input_api, output_api, file_filter=is_resource_no_instant).RunChecks()) |
61 results.extend(js_checker.JSChecker( | 61 results.extend(js_checker.JSChecker( |
62 input_api, output_api, file_filter=is_resource).RunChecks()) | 62 input_api, output_api, file_filter=is_resource).RunChecks()) |
63 finally: | 63 finally: |
64 sys.path = old_path | 64 sys.path = old_path |
65 | 65 |
66 return results | 66 return results |
OLD | NEW |