How to use the premailer.premailer._cache_parse_css_string function in premailer

To help you get started, we’ve selected a few premailer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Aristotle-Metadata-Enterprises / wcag-zoo / wcag_zoo / utils.py View on Github external
def _parse_css_string(self, css_body, validate=True):
        # We override this so we can do our rules altering for media queries
        if self.cache_css_parsing:
            sheet = _cache_parse_css_string(css_body, validate=validate)
        else:
            sheet = cssutils.parseString(css_body, validate=validate)

        _rules = []
        for rule in sheet:
            if rule.type == rule.MEDIA_RULE:
                if any([media in rule.media.mediaText for media in self.media_rules]):
                    for r in rule:
                        _rules.append(r)
            elif rule.type == rule.STYLE_RULE:
                _rules.append(rule)

        return _rules