def find_stylesheets_rules(tree, stylesheet_rules, url):
    """Find rules among stylesheet rules and imports."""
    for rule in stylesheet_rules:
        if rule.type == 'at-rule':
            if rule.lower_at_keyword == 'import' and rule.content is None:
                # TODO: support media types in @import
                url_token = tinycss2.parse_one_component_value(rule.prelude)
                if url_token.type not in ('string', 'url'):
                    continue
                css_url = parse_url(urljoin(url, url_token.value))
                stylesheet = tinycss2.parse_stylesheet(
                    tree.fetch_url(css_url, 'text/css').decode())
                url = css_url.geturl()
                yield from find_stylesheets_rules(tree, stylesheet, url)
            # TODO: support media types
            # if rule.lower_at_keyword == 'media':
        elif rule.type == 'qualified-rule':
            yield rule
Find rules among stylesheet rules and imports.
weasyprint/svg/css.py