o
    ™Ò\i©1  ã                   @  sÌ   U d Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
mZmZ ddlZddlmZ erAddlmZ ddlmZ dd	lmZmZ d
ed< zddlZW n ey[   dZe d¡ Y nw G dd„ deƒZdS )a,  Integration code for CSS selectors using `Soup Sieve <https://facelessuser.github.io/soupsieve/>`_ (pypi: ``soupsieve``).

Acquire a `CSS` object through the `element.Tag.css` attribute of
the starting point of your CSS selector, or (if you want to run a
selector against the entire document) of the `BeautifulSoup` object
itself.

The main advantage of doing this instead of using ``soupsieve``
functions is that you don't need to keep passing the `element.Tag` to be
selected against, since the `CSS` object is permanently scoped to that
`element.Tag`.

é    )Úannotations)Ú
ModuleType)ÚAnyÚcastÚIterableÚIteratorÚMutableSequenceÚOptionalÚTYPE_CHECKINGN)Ú_NamespaceMapping)Ú	SoupSieve)Úelement)Ú	ResultSetÚTagúOptional[ModuleType]Ú	soupsievezEThe soupsieve package is not installed. CSS selectors cannot be used.c                   @  s®   e Zd ZdZd3d4dd„Zd5dd„Zd6dd„Zd7dd„Z		d8d9dd „Z		d8d:d"d#„Z				d;d<d&d'„Z
			d;d=d)d*„Z		d8d>d,d-„Z		d8d?d/d0„Z		d8d@d1d2„ZdS )AÚCSSa”  A proxy object against the ``soupsieve`` library, to simplify its
    CSS selector API.

    You don't need to instantiate this class yourself; instead, use
    `element.Tag.css`.

    :param tag: All CSS selectors run by this object will use this as
        their starting point.

    :param api: An optional drop-in replacement for the ``soupsieve`` module,
        intended for use in unit tests.
    NÚtagúelement.TagÚapir   c                 C  s,   |d u rt }|d u rtdƒ‚|| _|| _d S )NzLCannot execute CSS selectors because the soupsieve package is not installed.)r   ÚNotImplementedErrorr   r   )Úselfr   r   © r   úh/var/www/www-root/data/www/176.119.141.140/sports-predictor/venv/lib/python3.10/site-packages/bs4/css.pyÚ__init__;   s   ÿ
zCSS.__init__ÚidentÚstrÚreturnc                 C  s"   t du rtdƒ‚tt| j |¡ƒS )zçEscape a CSS identifier.

        This is a simple wrapper around `soupsieve.escape() <https://facelessuser.github.io/soupsieve/api/#soupsieveescape>`_. See the
        documentation for that function for more information.
        NzMCannot escape CSS identifiers because the soupsieve package is not installed.)r   r   r   r   r   Úescape)r   r   r   r   r   r   E   s
   ÿz
CSS.escapeÚnsúOptional[_NamespaceMapping]Úselectc                 C  s"   t || jjƒs|du r| jj}|S )z%Normalize a dictionary of namespaces.N)Ú
isinstancer   r   r   Ú_namespaces)r   r   r!   r   r   r   Ú_nsQ   s   zCSS._nsÚresultsúMutableSequence[Tag]úResultSet[Tag]c                 C  s   ddl m} |d|ƒS )a?  Normalize a list of results to a py:class:`ResultSet`.

        A py:class:`ResultSet` is more consistent with the rest of
        Beautiful Soup's API, and :py:meth:`ResultSet.__getattr__` has
        a helpful error message if you try to treat a list of results
        as a single result (a common mistake).
        r   )r   N)Úbs4r   )r   r%   r   r   r   r   Ú_rs\   s   	
zCSS._rsr   Ú
namespacesÚflagsÚintÚkwargsr   r   c                 K  s    | j j||  ||¡|fi |¤ŽS )a  Pre-compile a selector and return the compiled object.

        :param selector: A CSS selector.

        :param namespaces: A dictionary mapping namespace prefixes
           used in the CSS selector to namespace URIs. By default,
           Beautiful Soup will use the prefixes it encountered while
           parsing the document.

        :param flags: Flags to be passed into Soup Sieve's
            `soupsieve.compile() <https://facelessuser.github.io/soupsieve/api/#soupsievecompile>`_ method.

        :param kwargs: Keyword arguments to be passed into Soup Sieve's
           `soupsieve.compile() <https://facelessuser.github.io/soupsieve/api/#soupsievecompile>`_ method.

        :return: A precompiled selector object.
        :rtype: soupsieve.SoupSieve
        )r   Úcompiler$   ©r   r!   r*   r+   r-   r   r   r   r.   i   s    zCSS.compileúelement.Tag | Nonec                 K  ó$   | j j|| j|  ||¡|fi |¤ŽS )aÁ  Perform a CSS selection operation on the current Tag and return the
        first result, if any.

        This uses the Soup Sieve library. For more information, see
        that library's documentation for the `soupsieve.select_one() <https://facelessuser.github.io/soupsieve/api/#soupsieveselect_one>`_ method.

        :param selector: A CSS selector.

        :param namespaces: A dictionary mapping namespace prefixes
           used in the CSS selector to namespace URIs. By default,
           Beautiful Soup will use the prefixes it encountered while
           parsing the document.

        :param flags: Flags to be passed into Soup Sieve's
            `soupsieve.select_one() <https://facelessuser.github.io/soupsieve/api/#soupsieveselect_one>`_ method.

        :param kwargs: Keyword arguments to be passed into Soup Sieve's
           `soupsieve.select_one() <https://facelessuser.github.io/soupsieve/api/#soupsieveselect_one>`_ method.
        )r   Ú
select_oner   r$   r/   r   r   r   r2   „   s
   ÿÿzCSS.select_oneÚlimitúResultSet[element.Tag]c              	   K  s8   |du rd}|   | jj|| j|  ||¡||fi |¤Ž¡S )aÙ  Perform a CSS selection operation on the current `element.Tag`.

        This uses the Soup Sieve library. For more information, see
        that library's documentation for the `soupsieve.select() <https://facelessuser.github.io/soupsieve/api/#soupsieveselect>`_ method.

        :param selector: A CSS selector.

        :param namespaces: A dictionary mapping namespace prefixes
            used in the CSS selector to namespace URIs. By default,
            Beautiful Soup will pass in the prefixes it encountered while
            parsing the document.

        :param limit: After finding this number of results, stop looking.

        :param flags: Flags to be passed into Soup Sieve's
            `soupsieve.select() <https://facelessuser.github.io/soupsieve/api/#soupsieveselect>`_ method.

        :param kwargs: Keyword arguments to be passed into Soup Sieve's
           `soupsieve.select() <https://facelessuser.github.io/soupsieve/api/#soupsieveselect>`_ method.
        Nr   )r)   r   r!   r   r$   ©r   r!   r*   r3   r+   r-   r   r   r   r!   ¢   s   ÿÿÿz
CSS.selectúIterator[element.Tag]c                 K  s&   | j j|| j|  ||¡||fi |¤ŽS )aU  Perform a CSS selection operation on the current `element.Tag`.

        This uses the Soup Sieve library. For more information, see
        that library's documentation for the `soupsieve.iselect()
        <https://facelessuser.github.io/soupsieve/api/#soupsieveiselect>`_
        method. It is the same as select(), but it returns a generator
        instead of a list.

        :param selector: A string containing a CSS selector.

        :param namespaces: A dictionary mapping namespace prefixes
            used in the CSS selector to namespace URIs. By default,
            Beautiful Soup will pass in the prefixes it encountered while
            parsing the document.

        :param limit: After finding this number of results, stop looking.

        :param flags: Flags to be passed into Soup Sieve's
            `soupsieve.iselect() <https://facelessuser.github.io/soupsieve/api/#soupsieveiselect>`_ method.

        :param kwargs: Keyword arguments to be passed into Soup Sieve's
           `soupsieve.iselect() <https://facelessuser.github.io/soupsieve/api/#soupsieveiselect>`_ method.
        )r   Úiselectr   r$   r5   r   r   r   r7   Ç   s
   ÿÿzCSS.iselectúOptional[element.Tag]c                 K  r1   )aÅ  Find the `element.Tag` closest to this one that matches the given selector.

        This uses the Soup Sieve library. For more information, see
        that library's documentation for the `soupsieve.closest()
        <https://facelessuser.github.io/soupsieve/api/#soupsieveclosest>`_
        method.

        :param selector: A string containing a CSS selector.

        :param namespaces: A dictionary mapping namespace prefixes
            used in the CSS selector to namespace URIs. By default,
            Beautiful Soup will pass in the prefixes it encountered while
            parsing the document.

        :param flags: Flags to be passed into Soup Sieve's
            `soupsieve.closest() <https://facelessuser.github.io/soupsieve/api/#soupsieveclosest>`_ method.

        :param kwargs: Keyword arguments to be passed into Soup Sieve's
           `soupsieve.closest() <https://facelessuser.github.io/soupsieve/api/#soupsieveclosest>`_ method.

        )r   Úclosestr   r$   r/   r   r   r   r9   ê   s
   ÿÿzCSS.closestÚboolc              	   K  s*   t t| jj|| j|  ||¡|fi |¤ŽƒS )aÇ  Check whether or not this `element.Tag` matches the given CSS selector.

        This uses the Soup Sieve library. For more information, see
        that library's documentation for the `soupsieve.match()
        <https://facelessuser.github.io/soupsieve/api/#soupsievematch>`_
        method.

        :param: a CSS selector.

        :param namespaces: A dictionary mapping namespace prefixes
            used in the CSS selector to namespace URIs. By default,
            Beautiful Soup will pass in the prefixes it encountered while
            parsing the document.

        :param flags: Flags to be passed into Soup Sieve's
            `soupsieve.match()
            <https://facelessuser.github.io/soupsieve/api/#soupsievematch>`_
            method.

        :param kwargs: Keyword arguments to be passed into SoupSieve's
            `soupsieve.match()
            <https://facelessuser.github.io/soupsieve/api/#soupsievematch>`_
            method.
        )r   r:   r   Úmatchr   r$   r/   r   r   r   r;   
  s   ÿÿþz	CSS.matchc              	   K  s*   |   | jj|| j|  ||¡|fi |¤Ž¡S )aN  Filter this `element.Tag`'s direct children based on the given CSS selector.

        This uses the Soup Sieve library. It works the same way as
        passing a `element.Tag` into that library's `soupsieve.filter()
        <https://facelessuser.github.io/soupsieve/api/#soupsievefilter>`_
        method. For more information, see the documentation for
        `soupsieve.filter()
        <https://facelessuser.github.io/soupsieve/api/#soupsievefilter>`_.

        :param namespaces: A dictionary mapping namespace prefixes
            used in the CSS selector to namespace URIs. By default,
            Beautiful Soup will pass in the prefixes it encountered while
            parsing the document.

        :param flags: Flags to be passed into Soup Sieve's
            `soupsieve.filter()
            <https://facelessuser.github.io/soupsieve/api/#soupsievefilter>`_
            method.

        :param kwargs: Keyword arguments to be passed into SoupSieve's
            `soupsieve.filter()
            <https://facelessuser.github.io/soupsieve/api/#soupsievefilter>`_
            method.
        )r)   r   Úfilterr   r$   r/   r   r   r   r<   0  s   ÿÿÿz
CSS.filter)N)r   r   r   r   )r   r   r   r   )r   r    r!   r   r   r    )r%   r&   r   r'   )Nr   )
r!   r   r*   r    r+   r,   r-   r   r   r   )
r!   r   r*   r    r+   r,   r-   r   r   r0   )Nr   r   )r!   r   r*   r    r3   r,   r+   r,   r-   r   r   r4   )r!   r   r*   r    r3   r,   r+   r,   r-   r   r   r6   )
r!   r   r*   r    r+   r,   r-   r   r   r8   )
r!   r   r*   r    r+   r,   r-   r   r   r:   )
r!   r   r*   r    r+   r,   r-   r   r   r4   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r$   r)   r.   r2   r!   r7   r9   r;   r<   r   r   r   r   r   -   s:    



üü!û(û&ü#ü)ür   )r@   Ú
__future__r   Útypesr   Útypingr   r   r   r   r   r	   r
   ÚwarningsÚbs4._typingr   r   r   r(   r   Úbs4.elementr   r   Ú__annotations__ÚImportErrorÚwarnÚobjectr   r   r   r   r   Ú<module>   s(    $	ÿþ