| OLD | NEW |
| 1 # Copyright 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 depot_tools, and see | 8 for more details about the presubmit API built into depot_tools, 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. |
| 11 """ | 11 """ |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 re.DOTALL | re.VERBOSE) | 45 re.DOTALL | re.VERBOSE) |
| 46 return at_reg.sub('\\1', s) | 46 return at_reg.sub('\\1', s) |
| 47 | 47 |
| 48 def _remove_comments(s): | 48 def _remove_comments(s): |
| 49 return re.sub(re.compile(r'/\*.*?\*/', re.DOTALL), '', s) | 49 return re.sub(re.compile(r'/\*.*?\*/', re.DOTALL), '', s) |
| 50 | 50 |
| 51 def _remove_mixins(s): | 51 def _remove_mixins(s): |
| 52 return re.sub(re.compile(r'--[\d\w-]+: {.*?};', re.DOTALL), '', s) | 52 return re.sub(re.compile(r'--[\d\w-]+: {.*?};', re.DOTALL), '', s) |
| 53 | 53 |
| 54 def _remove_template_expressions(s): | 54 def _remove_template_expressions(s): |
| 55 return re.sub(re.compile(r'\$i18n{[^}]*}', re.DOTALL), '', s) | 55 return re.sub(re.compile(r'\${[^}]*}', re.DOTALL), '', s) |
| 56 | 56 |
| 57 def _remove_grit(s): | 57 def _remove_grit(s): |
| 58 grit_reg = re.compile(r""" | 58 grit_reg = re.compile(r""" |
| 59 <if[^>]+>.*?<\s*/\s*if[^>]*>| # <if> contents </if> | 59 <if[^>]+>.*?<\s*/\s*if[^>]*>| # <if> contents </if> |
| 60 <include[^>]+> # <include> | 60 <include[^>]+> # <include> |
| 61 """, | 61 """, |
| 62 re.DOTALL | re.VERBOSE) | 62 re.DOTALL | re.VERBOSE) |
| 63 return re.sub(grit_reg, '', s) | 63 return re.sub(grit_reg, '', s) |
| 64 | 64 |
| 65 def _rgb_from_hex(s): | 65 def _rgb_from_hex(s): |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 error += check['after'](line) | 403 error += check['after'](line) |
| 404 check_errors.append(error) | 404 check_errors.append(error) |
| 405 if len(check_errors) > 0: | 405 if len(check_errors) > 0: |
| 406 file_errors.append('- %s\n%s' % | 406 file_errors.append('- %s\n%s' % |
| 407 (check['desc'], '\n'.join(check_errors))) | 407 (check['desc'], '\n'.join(check_errors))) |
| 408 if file_errors: | 408 if file_errors: |
| 409 results.append(self.output_api.PresubmitPromptWarning( | 409 results.append(self.output_api.PresubmitPromptWarning( |
| 410 '%s:\n%s' % (f[0], '\n\n'.join(file_errors)))) | 410 '%s:\n%s' % (f[0], '\n\n'.join(file_errors)))) |
| 411 | 411 |
| 412 return results | 412 return results |
| OLD | NEW |