# Copyright 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Presubmit script for Chromium WebUI resources. See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for more details about the presubmit API built into depot_tools, and see http://www.chromium.org/developers/web-development-style-guide for the rules we're checking against here. """ # TODO(dbeam): Real CSS parser? https://github.com/danbeam/css-py/tree/css3 class CSSChecker(object): def __init__(self, input_api, output_api, file_filter=None): self.input_api = input_api self.output_api = output_api self.file_filter = file_filter def RunChecks(self): # We use this a lot, so make a nick name variable. re = self.input_api.re def _collapseable_hex(s): return (len(s) == 6 and s[0] == s[1] and s[2] == s[3] and s[4] == s[5]) def _is_gray(s): return s[0] == s[1] == s[2] if len(s) == 3 else s[0:2] == s[2:4] == s[4:6] def _remove_all(s): s = _remove_grit(s) s = _remove_ats(s) s = _remove_comments(s) s = _remove_template_expressions(s) s = _remove_mixins(s) return s def _extract_inline_style(s): return '\n'.join(re.findall(r'