# 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)
        :param css_bytes:
            A CSS stylesheet as a byte string.
        :param protocol_encoding:
            The "charset" parameter of a "Content-Type" HTTP header (if any),
            or similar metadata for other protocols.
        :param linking_encoding:
            ``<link charset="">`` or other metadata from the linking mechanism
            (if any)
        :param document_encoding:
            Encoding of the referring style sheet or document (if any)
        :return:
            A :class:`Stylesheet`.

        """
        css_unicode, encoding = decode(css_bytes, protocol_encoding,
                                       linking_encoding, document_encoding)
        return self.parse_stylesheet(css_unicode, encoding=encoding)

    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`.

        """

# 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)

        :param css_bytes:
            A CSS stylesheet as a byte string.
        :param protocol_encoding:
            The "charset" parameter of a "Content-Type" HTTP header (if any),
            or similar metadata for other protocols.
        :param linking_encoding:
            ``<link charset="">`` or other metadata from the linking mechanism
            (if any)
        :param document_encoding:
            Encoding of the referring style sheet or document (if any)
        :return:
            A :class:`Stylesheet`.

        """
        css_unicode, encoding = decode(css_bytes, protocol_encoding,
                                       linking_encoding, document_encoding)
        return self.parse_stylesheet(css_unicode, encoding=encoding)

    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)