Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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