Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: chrome/browser/web_dev_style/css_checker.py

Issue 514403002: [Presubmit] Make CSS checker ignore '@' inside of strings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update test case naming. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 @\w+[^'"]*?{ # @at-keyword selector junk {
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 }""",
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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 '%s:\n%s' % (f[0], '\n\n'.join(file_errors)))) 363 '%s:\n%s' % (f[0], '\n\n'.join(file_errors))))
364 364
365 if results: 365 if results:
366 # Add your name if you're here often mucking around in the code. 366 # Add your name if you're here often mucking around in the code.
367 authors = ['dbeam@chromium.org'] 367 authors = ['dbeam@chromium.org']
368 results.append(self.output_api.PresubmitNotifyResult( 368 results.append(self.output_api.PresubmitNotifyResult(
369 'Was the CSS checker useful? Send feedback or hate mail to %s.' % 369 'Was the CSS checker useful? Send feedback or hate mail to %s.' %
370 ', '.join(authors))) 370 ', '.join(authors)))
371 371
372 return results 372 return results
OLDNEW
« chrome/browser/test_presubmit.py ('K') | « chrome/browser/test_presubmit.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698