OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 re.DOTALL | re.VERBOSE) | 48 re.DOTALL | re.VERBOSE) |
49 return at_reg.sub('\\1', s) | 49 return at_reg.sub('\\1', s) |
50 | 50 |
51 def _remove_comments(s): | 51 def _remove_comments(s): |
52 return re.sub(re.compile(r'/\*.*?\*/', re.DOTALL), '', s) | 52 return re.sub(re.compile(r'/\*.*?\*/', re.DOTALL), '', s) |
53 | 53 |
54 def _remove_mixins(s): | 54 def _remove_mixins(s): |
55 return re.sub(re.compile(r'--[\d\w-]+: {.*?};', re.DOTALL), '', s) | 55 return re.sub(re.compile(r'--[\d\w-]+: {.*?};', re.DOTALL), '', s) |
56 | 56 |
57 def _remove_template_expressions(s): | 57 def _remove_template_expressions(s): |
58 return re.sub(re.compile(r'\${[^}]*}', re.DOTALL), '', s) | 58 return re.sub(re.compile(r'\$i18n{[^}]*}', re.DOTALL), '', s) |
59 | 59 |
60 def _remove_grit(s): | 60 def _remove_grit(s): |
61 grit_reg = re.compile(r""" | 61 grit_reg = re.compile(r""" |
62 <if[^>]+>.*?<\s*/\s*if[^>]*>| # <if> contents </if> | 62 <if[^>]+>.*?<\s*/\s*if[^>]*>| # <if> contents </if> |
63 <include[^>]+> # <include> | 63 <include[^>]+> # <include> |
64 """, | 64 """, |
65 re.DOTALL | re.VERBOSE) | 65 re.DOTALL | re.VERBOSE) |
66 return re.sub(grit_reg, '', s) | 66 return re.sub(grit_reg, '', s) |
67 | 67 |
68 def _rgb_from_hex(s): | 68 def _rgb_from_hex(s): |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 error += check['after'](line) | 413 error += check['after'](line) |
414 check_errors.append(error) | 414 check_errors.append(error) |
415 if len(check_errors) > 0: | 415 if len(check_errors) > 0: |
416 file_errors.append('- %s\n%s' % | 416 file_errors.append('- %s\n%s' % |
417 (check['desc'], '\n'.join(check_errors))) | 417 (check['desc'], '\n'.join(check_errors))) |
418 if file_errors: | 418 if file_errors: |
419 results.append(self.output_api.PresubmitPromptWarning( | 419 results.append(self.output_api.PresubmitPromptWarning( |
420 '%s:\n%s' % (f[0], '\n\n'.join(file_errors)))) | 420 '%s:\n%s' % (f[0], '\n\n'.join(file_errors)))) |
421 | 421 |
422 return results | 422 return results |
OLD | NEW |