# Path: tinycsscheme/tinycss/tokenizer.py
# def tokenize_grouped(css_source, ignore_comments=True):
#     """
#     :param css_source:
#         CSS as an unicode string
#     :param ignore_comments:
#         if true (the default) comments will not be included in the
#         return value
#     :return:
#         An iterator of :class:`Token`
# 
#     """
#     return regroup(tokenize_flat(css_source, ignore_comments))


from itertools import chain, islice
from .decoding import decode
from .token_data import TokenList
from .tokenizer import tokenize_grouped
from .parsing import (strip_whitespace, remove_whitespace, split_on_comma,
                      validate_value, validate_block, validate_any, ParseError)
    def parse_stylesheet(self, css_unicode, encoding=None):
        """Parse a stylesheet from an Unicode string.

        :param css_unicode:
            A CSS stylesheet as an unicode string.
        :param encoding:
            The character encoding used to decode the stylesheet from bytes,
            if any.
        :return:
            A :class:`Stylesheet`.

        """
        tokens = tokenize_grouped(css_unicode)
        if encoding:
            tokens = _remove_at_charset(tokens)
        rules, errors = self.parse_rules(tokens, context='stylesheet')
        return Stylesheet(rules, errors, encoding)

    def parse_style_attr(self, css_source):
        """Parse a "style" attribute (eg. of an HTML element).

        This method only accepts Unicode as the source (HTML) document
        is supposed to handle the character encoding.

        :param css_source:
            The attribute value, as an unicode string.
        :return:
            A tuple of the list of valid :class:`Declaration` and
            a list of :class:`~.parsing.ParseError`.
        """

# Path: tinycsscheme/tinycss/tokenizer.py
# def tokenize_grouped(css_source, ignore_comments=True):
#     """
#     :param css_source:
#         CSS as an unicode string
#     :param ignore_comments:
#         if true (the default) comments will not be included in the
#         return value
#     :return:
#         An iterator of :class:`Token`
# 
#     """
#     return regroup(tokenize_flat(css_source, ignore_comments))


# Path: tinycsscheme/tinycss/css21.py
from itertools import chain, islice
from .decoding import decode
from .token_data import TokenList
from .tokenizer import tokenize_grouped
from .parsing import (strip_whitespace, remove_whitespace, split_on_comma,
                      validate_value, validate_block, validate_any, ParseError)

    def parse_stylesheet(self, css_unicode, encoding=None):
        """Parse a stylesheet from an Unicode string.

        :param css_unicode:
            A CSS stylesheet as an unicode string.
        :param encoding:
            The character encoding used to decode the stylesheet from bytes,
            if any.
        :return:
            A :class:`Stylesheet`.

        """
        tokens = tokenize_grouped(css_unicode)
        if encoding:
            tokens = _remove_at_charset(tokens)
        rules, errors = self.parse_rules(tokens, context='stylesheet')
        return Stylesheet(rules, errors, encoding)

    def parse_style_attr(self, css_source):
        """Parse a "style" attribute (eg. of an HTML element).

        This method only accepts Unicode as the source (HTML) document
        is supposed to handle the character encoding.

        :param css_source:
            The attribute value, as an unicode string.
        :return:
            A tuple of the list of valid :class:`Declaration` and
            a list of :class:`~.parsing.ParseError`.
        """

        return self.parse_declaration_list(tokenize_grouped(css_source))