� J�g�1����UdZddlmZddlmZddlmZmZmZm Z m Z m Z ddl Z ddl mZe rddlmZddlmZdd lmZmZd ed < ddlZn#e$rdZe jd ��YnwxYwGd �de��ZdS)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�Optional� TYPE_CHECKINGN)�_NamespaceMapping)� SoupSieve)�element)� ResultSet�Tag�Optional[ModuleType]� soupsievezEThe soupsieve package is not installed. CSS selectors cannot be used.c��eZdZdZd(d)d�Zd*d �Zd+d�Zd,d�Z d-d.d�Z d-d/d�Z d0d1d �Z d0d2d"�Z d-d3d$�Z d-d4d&�Z d-d5d'�ZdS)6�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�apirc�V�|�t}|�td���||_||_dS)NzLCannot execute CSS selectors because the soupsieve package is not installed.)r�NotImplementedErrorrr)�selfrrs �W/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/bs4/css.py�__init__z CSS.__init__:s:�� �;��C� �;�%�^��� ����������ident�str�returnc��t�td���tt|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.)rrrrr�escape)rrs rr!z CSS.escapeDs?�� � �%�_��� ��C������/�/�0�0�0r�ns�Optional[_NamespaceMapping]�selectc�V�t||jj��s|� |jj}|S)z%Normalize a dictionary of namespaces.)� isinstancerr r� _namespaces)rr"r$s r�_nszCSS._nsPs0���&�$�(�"4�5�5� &�"�*���%�B�� r�results� Iterable[Tag]�ResultSet[Tag]c�&�ddlm}|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)rN)�bs4r)rr)rs r�_rszCSS._rs[s(�� "�!�!�!�!�!��y��w�'�'�'rr� namespaces�flags�int�kwargsrr c �T�|jj||�||��|fi|��S)aPre-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(�rr$r/r0r2s rr4z CSS.compilehs3��2 �t�x�������V�(D�(D�e�V�V�v�V�V�Vr�element.Tag | Nonec �`�|jj||j|�||��|fi|��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_onerr(r5s rr8zCSS.select_one�sC��4#�t�x�"� �D�H�d�h�h�z�6�:�:�E� � �EK� � � r�limit�ResultSet[element.Tag]c ��|�d}|�|jj||j|�||��||fi|����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.rr$rr(�rr$r/r9r0r2s rr$z CSS.select�s_��8 �=��E��x�x� �D�H�O����$�(�(�:�v�">�">��u� � �PV� � � � � r�Iterator[element.Tag]c �b�|jj||j|�||��||fi|��S)aUPerform 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�iselectrr(r<s rr?z CSS.iselect�sE��> �t�x�� �D�H�d�h�h�z�6�:�:�E�5� � �LR� � � r�Optional[element.Tag]c �`�|jj||j|�||��|fi|��S)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�closestrr(r5s rrBz CSS.closest�sC��8 �t�x�� �D�H�d�h�h�z�6�:�:�E� � �EK� � � r�boolc ��tt|jj||j|�||��|fi|����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. )rrCr�matchrr(r5s rrEz CSS.match sR��>� � �D�H�N����$�(�(�:�v�">�">�� � �IO� � � � � rc ��|�|jj||j|�||��|fi|����S)aNFilter 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�filterrr(r5s rrGz CSS.filter/sS��>�x�x� �D�H�O����$�(�(�:�v�">�">�� � �IO� � � � � r)N)rrrr)rrrr)r"r#r$rrr#)r)r*rr+)Nr) r$rr/r#r0r1r2rrr ) r$rr/r#r0r1r2rrr6)Nrr) r$rr/r#r9r1r0r1r2rrr:) r$rr/r#r9r1r0r1r2rrr=) r$rr/r#r0r1r2rrr@) r$rr/r#r0r1r2rrrC) r$rr/r#r0r1r2rrr:)�__name__� __module__� __qualname__�__doc__rr!r(r.r4r8r$r?rBrErG�rrrr,sj������ � ������ 1� 1� 1� 1� � � � � (� (� (� (� 37�� W�W�W�W�W�<37��  � � � � �B37��� # �# �# �# �# �P37��� ! �! �! �! �! �L37��  � � � � �F37�� $ �$ �$ �$ �$ �R37�� # �# �# �# �# �# �# rr)rK� __future__r�typesr�typingrrrrr r �warnings� bs4._typingr rr r-r � bs4.elementrr�__annotations__� ImportError�warn�objectrrLrr�<module>rWs��� � � �#�"�"�"�"�"���������������������������)�)�)�)�)�)��+�#�#�#�#�#�#�������*�*�*�*�*�*�*�*�����������������I��H�M�O����������f �f �f �f �f �&�f �f �f �f �f s�A � A%�$A%
Memory