HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/tinycss2/__pycache__/parser.cpython-310.pyc
o

we�5�@s�ddlmZmZmZmZddlmZddd�Zdd�Zddd	�Z	dd
d�Z
dd
�Zdd�Zddd�Z
ddd�Zddd�Zddd�Zdd�Zdd�ZdS)�)�AtRule�Declaration�
ParseError�
QualifiedRule)�parse_component_value_listFcCst|t�r
t||�}t|�S)aqIterate component values out of string or component values iterable.

    :type input: :obj:`str` or :term:`iterable`
    :param input: A string or an iterable of :term:`component values`.
    :type skip_comments: :obj:`bool`
    :param skip_comments: If the input is a string, ignore all CSS comments.
    :returns: An iterator yielding :term:`component values`.

    )�
isinstance�strr�iter)�input�
skip_comments�r�H/home/arjun/projects/env/lib/python3.10/site-packages/tinycss2/parser.py�_to_token_iterators

rcCs |D]}|jdvr
|SqdS)z�Return the next significant (neither whitespace or comment) token.

    :type tokens: :term:`iterator`
    :param tokens: An iterator yielding :term:`component values`.
    :returns: A :term:`component value`, or :obj:`None`.

    ��
whitespace�commentN)�type)�tokens�tokenrrr
�_next_significants

��rcCsNt||�}t|�}t|�}|durtdddd�S|dur%t|j|jdd�S|S)a�Parse a single :diagram:`component value`.

    This is used e.g. for an attribute value
    referred to by ``attr(foo length)``.

    :type input: :obj:`str` or :term:`iterable`
    :param input: A string or an iterable of :term:`component values`.
    :type skip_comments: :obj:`bool`
    :param skip_comments: If the input is a string, ignore all CSS comments.
    :returns:
        A :term:`component value` (that is neither whitespace or comment),
        or a :class:`~tinycss2.ast.ParseError`.

    Nr�empty�Input is empty�extra-inputzGot more than one token)rrr�source_line�
source_column)r
rr�first�secondrrr
�parse_one_component_value"s

�rcCs2t||�}t|�}|durtdddd�St||�S)a?Parse a single :diagram:`declaration`.

    This is used e.g. for a declaration in an `@supports
    <https://drafts.csswg.org/css-conditional/#at-supports>`_ test.

    :type input: :obj:`str` or :term:`iterable`
    :param input: A string or an iterable of :term:`component values`.
    :type skip_comments: :obj:`bool`
    :param skip_comments: If the input is a string, ignore all CSS comments.
    :returns:
        A :class:`~tinycss2.ast.Declaration`
        or :class:`~tinycss2.ast.ParseError`.

    Any whitespace or comment before the ``:`` colon is dropped.

    Nrrr)rrr�_parse_declaration)r
rr�first_tokenrrr
�parse_one_declaration>s


r c	Cs|}|jdkrt|j|jdd|j�St|�}|dur$t|j|jdd�S|dkr4t|j|jdd|j�Sg}d}t|�D].\}}|dkrM|d	krMd
}|}n|d
kr^|jdkr^|jdkr^d}n|jdvred}|�|�q<|dkrt||d�=t|j|j|j	|j||dk�S)
a�Parse a declaration.

    Consume :obj:`tokens` until the end of the declaration or the first error.

    :type first_token: :term:`component value`
    :param first_token: The first component value of the rule.
    :type tokens: :term:`iterator`
    :param tokens: An iterator yielding :term:`component values`.
    :returns:
        A :class:`~tinycss2.ast.Declaration`
        or :class:`~tinycss2.ast.ParseError`.

    �ident�invalidz.Expected <ident> for declaration name, got %s.Nz,Expected ':' after declaration name, got EOF�:z,Expected ':' after declaration name, got %s.�value�!�bang�	importantr)
rrrrr�	enumerate�lower_value�appendrr$)	rr�name�colonr$�state�ir�
bang_positionrrr
rVsF
�����


�rcCs2g}|D]
}|dkrn|�|�qt|t|��S)z=Like :func:`_parse_declaration`, but stop at the first ``;``.�;)r*rr	)rr�other_declaration_tokensrrrr
�_consume_declaration_in_list�sr2cCs�t||�}g}|D]6}|jdkr|s|�|�q	|jdkr%|s$|�|�q	|jdkr3|�t||��q	|dkr?|�t||��q	|S)uMParse a :diagram:`declaration list` (which may also contain at-rules).

    This is used e.g. for the :attr:`~tinycss2.ast.QualifiedRule.content`
    of a style rule or ``@page`` rule,
    or for the ``style`` attribute of an HTML element.

    In contexts that don’t expect any at-rule,
    all :class:`~tinycss2.ast.AtRule` objects
    should simply be rejected as invalid.

    :type input: :obj:`str` or :term:`iterable`
    :param input: A string or an iterable of :term:`component values`.
    :type skip_comments: :obj:`bool`
    :param skip_comments:
        Ignore CSS comments at the top-level of the list.
        If the input is a string, ignore all comments.
    :type skip_whitespace: :obj:`bool`
    :param skip_whitespace:
        Ignore whitespace at the top-level of the list.
        Whitespace is still preserved
        in the :attr:`~tinycss2.ast.Declaration.value` of declarations
        and the :attr:`~tinycss2.ast.AtRule.prelude`
        and :attr:`~tinycss2.ast.AtRule.content` of at-rules.
    :returns:
        A list of
        :class:`~tinycss2.ast.Declaration`,
        :class:`~tinycss2.ast.AtRule`,
        :class:`~tinycss2.ast.Comment` (if ``skip_comments`` is false),
        :class:`~tinycss2.ast.WhitespaceToken`
        (if ``skip_whitespace`` is false),
        and :class:`~tinycss2.ast.ParseError` objects

    rr�
at-keywordr0)rrr*�_consume_at_ruler2�r
r�skip_whitespacer�resultrrrr
�parse_declaration_list�s"
"

�

�
�r8cCs^t||�}t|�}|durtdddd�St||�}t|�}|dur-t|j|jdd|j�S|S)a�Parse a single :diagram:`qualified rule` or :diagram:`at-rule`.

    This would be used e.g. by `insertRule()
    <https://drafts.csswg.org/cssom/#dom-cssstylesheet-insertrule>`_
    in an implementation of CSSOM.

    :type input: :obj:`str` or :term:`iterable`
    :param input: A string or an iterable of :term:`component values`.
    :type skip_comments: :obj:`bool`
    :param skip_comments:
        If the input is a string, ignore all CSS comments.
    :returns:
        A :class:`~tinycss2.ast.QualifiedRule`,
        :class:`~tinycss2.ast.AtRule`,
        or :class:`~tinycss2.ast.ParseError` objects.

    Any whitespace or comment before or after the rule is dropped.

    Nrrrrz4Expected a single rule, got %s after the first rule.)rrr�
_consume_rulerrr)r
rrr�rule�nextrrr
�parse_one_rule�s


�r<cCs`t||�}g}|D]$}|jdkr|s|�|�q	|jdkr%|s$|�|�q	|�t||��q	|S)a�Parse a non-top-level :diagram:`rule list`.

    This is used for parsing the :attr:`~tinycss2.ast.AtRule.content`
    of nested rules like ``@media``.
    This differs from :func:`parse_stylesheet` in that
    top-level ``<!--`` and ``-->`` tokens are not ignored.

    :type input: :obj:`str` or :term:`iterable`
    :param input: A string or an iterable of :term:`component values`.
    :type skip_comments: :obj:`bool`
    :param skip_comments:
        Ignore CSS comments at the top-level of the list.
        If the input is a string, ignore all comments.
    :type skip_whitespace: :obj:`bool`
    :param skip_whitespace:
        Ignore whitespace at the top-level of the list.
        Whitespace is still preserved
        in the :attr:`~tinycss2.ast.QualifiedRule.prelude`
        and the :attr:`~tinycss2.ast.QualifiedRule.content` of rules.
    :returns:
        A list of
        :class:`~tinycss2.ast.QualifiedRule`,
        :class:`~tinycss2.ast.AtRule`,
        :class:`~tinycss2.ast.Comment` (if ``skip_comments`` is false),
        :class:`~tinycss2.ast.WhitespaceToken`
        (if ``skip_whitespace`` is false),
        and :class:`~tinycss2.ast.ParseError` objects.

    rr�rrr*r9r5rrr
�parse_rule_list�s


�

�r>cCsht||�}g}|D](}|jdkr|s|�|�q	|jdkr%|s$|�|�q	|dvr1|�t||��q	|S)a�Parse :diagram:`stylesheet` from text.

    This is used e.g. for a ``<style>`` HTML element.

    This differs from :func:`parse_rule_list` in that
    top-level ``<!--`` and ``-->`` tokens are ignored.
    This is a legacy quirk for the ``<style>`` HTML element.

    :type input: :obj:`str` or :term:`iterable`
    :param input: A string or an iterable of :term:`component values`.
    :type skip_comments: :obj:`bool`
    :param skip_comments:
        Ignore CSS comments at the top-level of the stylesheet.
        If the input is a string, ignore all comments.
    :type skip_whitespace: :obj:`bool`
    :param skip_whitespace:
        Ignore whitespace at the top-level of the stylesheet.
        Whitespace is still preserved
        in the :attr:`~tinycss2.ast.QualifiedRule.prelude`
        and the :attr:`~tinycss2.ast.QualifiedRule.content` of rules.
    :returns:
        A list of
        :class:`~tinycss2.ast.QualifiedRule`,
        :class:`~tinycss2.ast.AtRule`,
        :class:`~tinycss2.ast.Comment` (if ``skip_comments`` is false),
        :class:`~tinycss2.ast.WhitespaceToken`
        (if ``skip_whitespace`` is false),
        and :class:`~tinycss2.ast.ParseError` objects.

    rr)z<!--z-->r=r5rrr
�parse_stylesheets


�

��r?cCs�|jdkr
t||�S|jdkrg}|}n#|g}|D]}|jdkr$|}n|�|�qt|dj|djdd�St|j|j||j�S)a�Parse a qualified rule or at-rule.

    Consume just enough of :obj:`tokens` for this rule.

    :type first_token: :term:`component value`
    :param first_token: The first component value of the rule.
    :type tokens: :term:`iterator`
    :param tokens: An iterator yielding :term:`component values`.
    :returns:
        A :class:`~tinycss2.ast.QualifiedRule`,
        :class:`~tinycss2.ast.AtRule`,
        or :class:`~tinycss2.ast.ParseError`.

    r3�{} block���r"z1EOF reached before {} block for a qualified rule.)rr4r*rrrr�content)rr�prelude�blockrrrr
r9>s$



�
�r9cCsVg}d}|D]}|jdkr|j}n|dkrn|�|�qt|j|j|j|j||�S)a�Parse an at-rule.

    Consume just enough of :obj:`tokens` for this rule.

    :type at_keyword: :class:`AtKeywordToken`
    :param at_keyword: The at-rule keyword token starting this rule.
    :type tokens: :term:`iterator`
    :param tokens: An iterator yielding :term:`component values`.
    :returns:
        A :class:`~tinycss2.ast.QualifiedRule`,
        or :class:`~tinycss2.ast.ParseError`.

    Nr@r0)rrBr*rrrr$r))�
at_keywordrrCrBrrrr
r4as

�r4N)F)FF)�astrrrr�	tokenizerrrrrr rr2r8r<r>r?r9r4rrrr
�<module>s


1


2
"
,-#