Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 26 return (len(s) == 6 and s[0] == s[1] and s[2] == s[3] and s[4] == s[5]) | 26 return (len(s) == 6 and s[0] == s[1] and s[2] == s[3] and s[4] == s[5]) |
| 27 | 27 |
| 28 def _is_gray(s): | 28 def _is_gray(s): |
| 29 return s[0] == s[1] == s[2] if len(s) == 3 else s[0:2] == s[2:4] == s[4:6] | 29 return s[0] == s[1] == s[2] if len(s) == 3 else s[0:2] == s[2:4] == s[4:6] |
| 30 | 30 |
| 31 def _remove_all(s): | 31 def _remove_all(s): |
| 32 return _remove_grit(_remove_ats(_remove_comments(s))) | 32 return _remove_grit(_remove_ats(_remove_comments(s))) |
| 33 | 33 |
| 34 def _remove_ats(s): | 34 def _remove_ats(s): |
| 35 at_reg = re.compile(r""" | 35 at_reg = re.compile(r""" |
| 36 @\w+[^'"]*?{ # @at-keyword selector junk { | 36 @(?!\d+x\b)\w+[^'"]*?{ # @at-keyword selector junk {, not @2x |
| 37 (.*{.*?})+ # inner { curly } blocks, rules, and selector junk | 37 (.*{.*?})+ # inner { curly } blocks, rules, and selector junk |
| 38 .*?} # stuff up to the first end curly }""", | 38 .*?} # stuff up to the first end curly }""", |
|
Tyler Breisacher (Chromium)
2014/12/03 03:37:50
Actually I like the way the comments are all lined
Dan Beam
2014/12/03 05:35:45
Done.
| |
| 39 re.DOTALL | re.VERBOSE) | 39 re.DOTALL | re.VERBOSE) |
| 40 return at_reg.sub('\\1', s) | 40 return at_reg.sub('\\1', s) |
| 41 | 41 |
| 42 def _remove_comments(s): | 42 def _remove_comments(s): |
| 43 return re.sub(re.compile(r'/\*.*?\*/', re.DOTALL), '', s) | 43 return re.sub(re.compile(r'/\*.*?\*/', re.DOTALL), '', s) |
| 44 | 44 |
| 45 def _remove_grit(s): | 45 def _remove_grit(s): |
| 46 grit_reg = re.compile(r""" | 46 grit_reg = re.compile(r""" |
| 47 <if[^>]+>.*?<\s*/\s*if[^>]*>| # <if> contents </if> | 47 <if[^>]+>.*?<\s*/\s*if[^>]*>| # <if> contents </if> |
| 48 <include[^>]+> # <include>""", | 48 <include[^>]+> # <include>""", |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 '%s:\n%s' % (f[0], '\n\n'.join(file_errors)))) | 377 '%s:\n%s' % (f[0], '\n\n'.join(file_errors)))) |
| 378 | 378 |
| 379 if results: | 379 if results: |
| 380 # Add your name if you're here often mucking around in the code. | 380 # Add your name if you're here often mucking around in the code. |
| 381 authors = ['dbeam@chromium.org'] | 381 authors = ['dbeam@chromium.org'] |
| 382 results.append(self.output_api.PresubmitNotifyResult( | 382 results.append(self.output_api.PresubmitNotifyResult( |
| 383 'Was the CSS checker useful? Send feedback or hate mail to %s.' % | 383 'Was the CSS checker useful? Send feedback or hate mail to %s.' % |
| 384 ', '.join(authors))) | 384 ', '.join(authors))) |
| 385 | 385 |
| 386 return results | 386 return results |
| OLD | NEW |