OLD | NEW |
1 # Copyright 2014 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 | 4 |
5 """Presubmit script for HTML files in chrome/browser/resources. | 5 """Presubmit script for HTML files in chrome/browser/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. | 8 for more details about the presubmit API built into gcl. |
9 """ | 9 """ |
10 | 10 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 Checks whether the action comes from boolean control based on the HTML | 72 Checks whether the action comes from boolean control based on the HTML |
73 elements attributes. | 73 elements attributes. |
74 | 74 |
75 Args: | 75 Args: |
76 new_content_lines: List of changed lines. | 76 new_content_lines: List of changed lines. |
77 metric_name: The name for which the check should be done. | 77 metric_name: The name for which the check should be done. |
78 """ | 78 """ |
79 new_content = '\n'.join(new_content_lines) | 79 new_content = '\n'.join(new_content_lines) |
80 | 80 |
81 html_element_re = r'<(.*?)(^|\s+)metric\s*=\s*"%s"(.*?)>' % (metric_name) | 81 html_element_re = r'<(.*?)(^|\s+)metric\s*=\s*"%s"(.*?)>' % (metric_name) |
82 type_re = (r'datatype="boolean"|type="checkbox"|type="radio".*?' | 82 type_re = (r'datatype\s*=\s*"boolean"|type\s*=\s*"checkbox"|' |
83 'value=("true"|"false")') | 83 'type\s*=\s*"radio".*?value\s*=\s*("true"|"false")') |
84 | 84 |
85 match = input_api.re.search(html_element_re, new_content) | 85 match = input_api.re.search(html_element_re, new_content, input_api.re.DOTALL) |
86 return (match and | 86 return (match and |
87 any(input_api.re.search(type_re, match.group(i)) for i in (1, 3))) | 87 any(input_api.re.search(type_re, match.group(i)) for i in (1, 3))) |
88 | 88 |
89 | 89 |
90 def CheckChangeOnUpload(input_api, output_api): | 90 def CheckChangeOnUpload(input_api, output_api): |
91 return CheckUserActionUpdate(input_api, output_api, ACTION_XML_PATH) | 91 return CheckUserActionUpdate(input_api, output_api, ACTION_XML_PATH) |
92 | 92 |
93 | 93 |
94 def CheckChangeOnCommit(input_api, output_api): | 94 def CheckChangeOnCommit(input_api, output_api): |
95 return CheckUserActionUpdate(input_api, output_api, ACTION_XML_PATH) | 95 return CheckUserActionUpdate(input_api, output_api, ACTION_XML_PATH) |
OLD | NEW |