§
    ¥”j,5  ã                   ó`   — d dl mZ d dlmZ d dlmZ ddlmZmZ  G d„ d¦  «        Z	d„ Z
d	„ Zd
S )é    )Úcached_property)Úwarn)Úascii_loweré   )Úcompile_selector_listÚsplit_whitespacec                   óŽ  — e Zd ZdZedd„¦   «         Zedd„¦   «         Zed d„¦   «         Z	 dd„Zd„ Z	d	„ Z
d
„ Zd„ Zed„ ¦   «         Zed„ ¦   «         Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zed„ ¦   «         Zd„ Zd„ Zd„ Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Z ed„ ¦   «         Z!ed„ ¦   «         Z"dS )!ÚElementWrapperaí  Wrapper of :class:`xml.etree.ElementTree.Element` for Selector matching.

    This class should not be instanciated directly. :meth:`from_xml_root` or
    :meth:`from_html_root` should be used for the root element of a document,
    and other elements should be accessed (and wrappers generated) using
    methods such as :meth:`iter_children` and :meth:`iter_subtree`.

    :class:`ElementWrapper` objects compare equal if their underlying
    :class:`xml.etree.ElementTree.Element` do.

    Nc                 ó2   — |                       ||d¬¦  «        S )a.  Wrap for selector matching the root of an XML or XHTML document.

        :param root:
            An ElementTree :class:`xml.etree.ElementTree.Element`
            for the root element of a document.
            If the given element is not the root,
            selector matching will behave is if it were.
            In other words, selectors will be not be `scoped`_
            to the subtree rooted at that element.
        :returns:
            A new :class:`ElementWrapper`

        .. _scoped: https://drafts.csswg.org/selectors-4/#scoping

        F©Úin_html_document©Ú
_from_root©ÚclsÚrootÚcontent_languages      ú^/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/cssselect2/tree.pyÚfrom_xml_rootzElementWrapper.from_xml_root   s   € ð" �~Š~˜dÐ$4Àuˆ~ÑMÔMÐMó    c                 ó2   — |                       ||d¬¦  «        S )zæSame as :meth:`from_xml_root` with case-insensitive attribute names.

        Useful for documents parsed with an HTML parser like html5lib, which
        should be the case of documents with the ``text/html`` MIME type.

        Tr   r   r   s      r   Úfrom_html_rootzElementWrapper.from_html_root(   s   € ð �~Š~˜dÐ$4Àtˆ~ÑLÔLÐLr   Tc                 ól   — t          |d¦  «        r|                     ¦   «         } | |d dd ||¬¦  «        S )NÚgetrootr   )ÚparentÚindexÚpreviousr   r   )Úhasattrr   )r   r   r   r   s       r   r   zElementWrapper._from_root2   sM   € å�4˜Ñ#Ô#ð 	"Ø—<’<‘>”>ˆDØˆsØ˜ Q°Ø-Ð@PðRñ Rô Rð 	Rr   c                 ó¤   — || _         || _        || _        |�|j        | _        n|g| _        || _        || _        || _        d | _        d | _	        d S ©N)
Úetree_elementr   r   Úetree_childrenÚetree_siblingsr   r   Útransport_content_languageÚ
_ancestorsÚ_previous_siblings)Úselfr!   r   r   r   r   r   s          r   Ú__init__zElementWrapper.__init__:   sn   € ð +ˆÔð ˆŒð !ˆŒØÐð
 #)Ô"7ˆDÔÐà#0 /ˆDÔð ˆŒ
Ø 0ˆÔØ*:ˆÔ'ð ˆŒØ"&ˆÔÐÐr   c                 ó^   — t          | ¦  «        t          |¦  «        u o| j        |j        k    S r    )Útyper!   ©r'   Úothers     r   Ú__eq__zElementWrapper.__eq__V   s.   € å�‰JŒJ�$˜u™+œ+Ð%ð 6ØÔ %Ô"5Ò5ð	7r   c                 ó   — | |k     S r    © r+   s     r   Ú__ne__zElementWrapper.__ne__[   s   € Ø˜E’MÐ"Ð"r   c                 óH   — t          t          | ¦  «        | j        f¦  «        S r    )Úhashr*   r!   ©r'   s    r   Ú__hash__zElementWrapper.__hash__^   s   € Ý•T˜$‘Z”Z Ô!3Ð4Ñ5Ô5Ð5r   c              #   ó>   K  — |                       ¦   «         E d {V —† d S r    )Úiter_childrenr3   s    r   Ú__iter__zElementWrapper.__iter__a   s0   è è € Ø×%Ò%Ñ'Ô'Ð'Ð'Ð'Ð'Ð'Ð'Ð'Ð'Ð'r   c                 óf   — | j         €$| j        €dng | j        j        ¢| j        ‘R | _         | j         S )uÂ   Tuple of existing ancestors.

        Tuple of existing :class:`ElementWrapper` objects for this elementâ€™s
        ancestors, in reversed tree order, from :attr:`parent` to the root.

        Nr/   )r%   r   Ú	ancestorsr3   s    r   r9   zElementWrapper.ancestorsd   s>   € ð Œ?Ð"à”kÐ)��Ð/T°´Ô1FÐ/TÈÌÐ/TÐ/Tð ŒOàŒÐr   c                 óf   — | j         €$| j        €dng | j        j        ¢| j        ‘R | _         | j         S )u¨   Tuple of previous siblings.

        Tuple of existing :class:`ElementWrapper` objects for this elementâ€™s
        previous siblings, in reversed tree order.

        Nr/   )r&   r   Úprevious_siblingsr3   s    r   r;   z ElementWrapper.previous_siblingsq   sC   € ð Ô"Ð*à”mÐ+��ØA�$”-Ô1ÐA°4´=ÐAÐAð Ô#ð Ô&Ð&r   c              #   óN   K  — t          dt          ¦  «         | j        E d{V —† dS )u¨  Iterate over ancestors.

        Return an iterator of existing :class:`ElementWrapper` objects for this
        elementâ€™s ancestors, in reversed tree order (from :attr:`parent` to the
        root).

        The element itself is not included, this is an empty sequence for the
        root element.

        This method is deprecated and will be removed in version 0.7.0. Use
        :attr:`ancestors` instead.

        zfThis method is deprecated and will be removed in version 0.7.0. Use the "ancestors" attribute instead.N)r   ÚDeprecationWarningr9   r3   s    r   Úiter_ancestorszElementWrapper.iter_ancestors   sD   è è € õ 	ð5åñ	 ô 	 ð 	 ð ”>Ð!Ð!Ð!Ð!Ð!Ð!Ð!Ð!Ð!r   c              #   óN   K  — t          dt          ¦  «         | j        E d{V —† dS )u§  Iterate over previous siblings.

        Return an iterator of existing :class:`ElementWrapper` objects for this
        elementâ€™s previous siblings, in reversed tree order.

        The element itself is not included, this is an empty sequence for a
        first child or the root element.

        This method is deprecated and will be removed in version 0.7.0. Use
        :attr:`previous_siblings` instead.

        znThis method is deprecated and will be removed in version 0.7.0. Use the "previous_siblings" attribute instead.N)r   r=   r;   r3   s    r   Úiter_previous_siblingsz%ElementWrapper.iter_previous_siblings“   sE   è è € õ 	ð=åñ	 ô 	 ð 	 ð Ô)Ð)Ð)Ð)Ð)Ð)Ð)Ð)Ð)Ð)r   c              #   ób   K  — | j         €| V — dS | j                              ¦   «         E d{V —† dS )u£   Iterate over siblings.

        Return an iterator of newly-created :class:`ElementWrapper` objects for
        this elementâ€™s siblings, in tree order.

        N)r   r6   r3   s    r   Úiter_siblingszElementWrapper.iter_siblings¦   sI   è è € ð Œ;ÐØˆJˆJˆJˆJˆJà”{×0Ò0Ñ2Ô2Ð2Ð2Ð2Ð2Ð2Ð2Ð2Ð2Ð2r   c              #   óX   K  — d}|                       ¦   «         D ]}|r|V — || k    rd}ŒdS )u­   Iterate over next siblings.

        Return an iterator of newly-created :class:`ElementWrapper` objects for
        this elementâ€™s next siblings, in tree order.

        FTN)rB   )r'   ÚfoundÚsiblings      r   Úiter_next_siblingsz!ElementWrapper.iter_next_siblings²   sR   è è € ð ˆØ×)Ò)Ñ+Ô+ð 	ð 	ˆGØð Ø���Ø˜$ŠˆØ�øð		ð 	r   c              #   óŽ   K  — d}t          | j        ¦  «        D ]+\  }} t          | ¦  «        || ||| j        ¬¦  «        }|V — Œ,dS )u©   Iterate over children.

        Return an iterator of newly-created :class:`ElementWrapper` objects for
        this elementâ€™s child elements, in tree order.

        N)r   r   r   r   )Ú	enumerater"   r*   r   )r'   ÚchildÚiÚetree_childs       r   r6   zElementWrapper.iter_childrenÀ   sm   è è € ð ˆÝ'¨Ô(;Ñ<Ô<ð 	ð 	‰NˆAˆ{Ø•D˜‘J”JØ D°¸EØ!%Ô!6ð8ñ 8ô 8ˆEð ˆKˆKˆKˆKð		ð 	r   c              #   óè   K  — t          | g¦  «        g}|r\t          |d         d¦  «        }|€|                     ¦   «          n+|V — |                     |                     ¦   «         ¦  «         |°ZdS dS )a¨  Iterate over subtree.

        Return an iterator of newly-created :class:`ElementWrapper` objects for
        the entire subtree rooted at this element, in tree order.

        Unlike in other methods, the element itself *is* included.

        This loops over an entire document:

        .. code-block:: python

            for element in ElementWrapper.from_root(root_etree).iter_subtree():
                ...

        éÿÿÿÿN)ÚiterÚnextÚpopÚappendr6   )r'   ÚstackÚelements      r   Úiter_subtreezElementWrapper.iter_subtreeÎ   s‹   è è € õ  �t�f‘”�ˆØð 	6Ý˜5 œ9 dÑ+Ô+ˆGØˆØ—	’	‘”��à���Ø—’˜W×2Ò2Ñ4Ô4Ñ5Ô5Ð5ð ð 	6ð 	6ð 	6ð 	6ð 	6r   c                 ó   — d„ | D ¦   «         S )Nc                 ó‚   — g | ]<}t          |d ¦  «        r|gnt          |¦  «        D ]}|j        ­	|j        °|j        ‘ŒŒ=S )Útest)r   r   Úpseudo_elementÚnever_matchesrW   )Ú.0ÚselectorÚcompiled_selectors      r   ú
<listcomp>z+ElementWrapper._compile.<locals>.<listcomp>é   sr   € ð 1ð 1ð 1àå% h°Ñ7Ô7ð 5��
�
Ý*¨8Ñ4Ô4ð1ð 1ð "ð !Ô/Ð7Ø!Ô/ð 8ð Ô"ð
 8Ð7Ð7Ð7r   r/   )Ú	selectorss    r   Ú_compilezElementWrapper._compileç   s#   € ð1ð 1à%ð1ñ 1ô 1ð 	1r   c                 ó`   ‡ — t          ˆ fd„‰                      |¦  «        D ¦   «         ¦  «        S )zðReturn wether this elememt matches any of the given selectors.

        :param selectors:
            Each given selector is either a :class:`compiler.CompiledSelector`,
            or an argument to :func:`compile_selector_list`.

        c              3   ó.   •K  — | ]} |‰¦  «        V — Œd S r    r/   )rZ   rW   r'   s     €r   ú	<genexpr>z)ElementWrapper.matches.<locals>.<genexpr>ú   s+   øè è € ÐCÐC $�4�4˜‘:”:ÐCÐCÐCÐCÐCÐCr   )Úanyr_   ©r'   r^   s   ` r   ÚmatcheszElementWrapper.matchesò   s4   ø€ õ ÐCÐCÐCÐC¨$¯-ª-¸	Ñ*BÔ*BÐCÑCÔCÑCÔCÐCr   c                 ó  ‡— |                       |¦  «        Št          ‰¦  «        dk    r(t          ‰d         |                      ¦   «         ¦  «        S |r ˆfd„|                      ¦   «         D ¦   «         S t	          d¦  «        S )aÛ  Return elements, in tree order, that match any of given selectors.

        Selectors are `scoped`_ to the subtree rooted at this element.

        .. _scoped: https://drafts.csswg.org/selectors-4/#scoping

        :param selectors:
            Each given selector is either a :class:`compiler.CompiledSelector`,
            or an argument to :func:`compile_selector_list`.
        :returns:
            An iterator of newly-created :class:`ElementWrapper` objects.

        r   r   c              3   óT   •‡K  — | ]!Št          ˆfd „‰D ¦   «         ¦  «        ¯‰V — Œ"dS )c              3   ó.   •K  — | ]} |‰¦  «        V — Œd S r    r/   )rZ   rW   rS   s     €r   rb   z5ElementWrapper.query_all.<locals>.<genexpr>.<genexpr>  s+   øè è € Ð7Ð7¨�t�t˜G‘}”}Ð7Ð7Ð7Ð7Ð7Ð7r   N)rc   )rZ   rS   Útestss    @€r   rb   z+ElementWrapper.query_all.<locals>.<genexpr>  s[   øøè è € ð 9ð 9Ø#ÝÐ7Ð7Ð7Ð7°Ð7Ñ7Ô7Ñ7Ô7ð9Øð9ð 9ð 9ð 9ð 9ð 9r   r/   )r_   ÚlenÚfilterrT   rN   )r'   r^   ri   s     @r   Ú	query_allzElementWrapper.query_allü   s‘   ø€ ð —’˜iÑ(Ô(ˆÝˆu‰:Œ:˜Š?ˆ?Ý˜% œ( D×$5Ò$5Ñ$7Ô$7Ñ8Ô8Ð8Øð 	ð9ð 9ð 9ð 9Ø'+×'8Ò'8Ñ':Ô':ð9ñ 9ô 9ð 9õ ˜‘8”8ˆOr   c                 ó2   — t           | j        |Ž d¦  «        S )aj  Return first element that matches any of given selectors.

        :param selectors:
            Each given selector is either a :class:`compiler.CompiledSelector`,
            or an argument to :func:`compile_selector_list`.
        :returns:
            A newly-created :class:`ElementWrapper` object,
            or :obj:`None` if there is no match.

        N)rO   rl   rd   s     r   ÚqueryzElementWrapper.query  s   € õ �N�D”N IÐ.°Ñ5Ô5Ð5r   c                 ó$   — d„ | j         D ¦   «         S )a%  Children as a list of :class:`xml.etree.ElementTree.Element`.

        Other ElementTree nodes such as
        :func:`comments <xml.etree.ElementTree.Comment>` and
        :func:`processing instructions
        <xml.etree.ElementTree.ProcessingInstruction>`
        are not included.

        c                 óF   — g | ]}t          |j        t          ¦  «        ¯|‘ŒS r/   )Ú
isinstanceÚtagÚstr)rZ   rS   s     r   r]   z1ElementWrapper.etree_children.<locals>.<listcomp>,  s:   € ð -ð -ð -ØÝ˜'œ+¥sÑ+Ô+ð-Øð-ð -ð -r   )r!   r3   s    r   r"   zElementWrapper.etree_children!  s&   € ð-ð -Ø#'Ô#5ð-ñ -ô -ð 	-r   c                 óR   — t          | j        j        ¦  «        \  }}|| j        d<   |S )z,The local name of this element, as a string.Únamespace_url©Ú_split_etree_tagr!   rr   Ú__dict__©r'   ru   Ú
local_names      r   rz   zElementWrapper.local_name0  s.   € õ %5°TÔ5GÔ5KÑ$LÔ$LÑ!ˆ�zØ)6ˆŒ�oÑ&ØÐr   c                 óR   — t          | j        j        ¦  «        \  }}|| j        d<   |S )z/The namespace URL of this element, as a string.rz   rv   ry   s      r   ru   zElementWrapper.namespace_url7  s.   € õ %5°TÔ5GÔ5KÑ$LÔ$LÑ!ˆ�zØ&0ˆŒ�lÑ#ØÐr   c                 ó6   — | j                              d¦  «        S )z$The ID of this element, as a string.Úid)r!   Úgetr3   s    r   r}   zElementWrapper.id>  s   € ð Ô!×%Ò% dÑ+Ô+Ð+r   c                 ól   — t          t          | j                             dd¦  «        ¦  «        ¦  «        S )z:The classes of this element, as a :class:`set` of strings.ÚclassÚ )Úsetr   r!   r~   r3   s    r   ÚclasseszElementWrapper.classesC  s.   € õ Õ# DÔ$6×$:Ò$:¸7ÀBÑ$GÔ$GÑHÔHÑIÔIÐIr   c                 ó&  — | j                              d¦  «        }|�t          |¦  «        S | j        p
| j        dk    }|r+| j                              d¦  «        }|�t          |¦  «        S | j        �| j        j        S |r}d}| j                              d¦  «        }|D ]M}|                     dd¦  «        }t          |¦  «        dk    r"t          |                     d	¦  «        ¦  «        }ŒN|�t          |¦  «        S t          | j	        ¦  «        pdS )
z*The language of this element, as a string.z*{http://www.w3.org/XML/1998/namespace}langNzhttp://www.w3.org/1999/xhtmlÚlangz"{http://www.w3.org/1999/xhtml}metaz
http-equivr�   zcontent-languageÚcontent)
r!   r~   r   r   ru   r   r…   rN   Ú_parse_content_languager$   )r'   Úxml_langÚis_htmlr…   r   ÚiteratorÚmetaÚ
http_equivs           r   r…   zElementWrapper.langH  s6  € ð Ô%×)Ò)Ð*VÑWÔWˆØÐÝ˜xÑ(Ô(Ð(àÔ!ð AØÔÐ"@Ò@ð 	ð ð 	)ØÔ%×)Ò)¨&Ñ1Ô1ˆDØÐÝ" 4Ñ(Ô(Ð(ØŒ;Ð"Ø”;Ô#Ð#àð 	5Ø#ÐØÔ)×.Ò.Ð/SÑTÔTˆHØ ð Tð T�Ø!ŸXšX l°BÑ7Ô7�
Ý˜zÑ*Ô*Ð.@Ò@Ð@Ý'>¸t¿xºxÈ	Ñ?RÔ?RÑ'SÔ'SÐ$øØÐ+Ý"Ð#3Ñ4Ô4Ð4å& tÔ'FÑGÔGÐMÈ2ÐMr   c                 ó   ‡— | j         €dS d}dŠ| j         j        j        |k    o]| j         j                             d¦  «        d uo<| j        j        ‰k    p,t	          ˆfd„|                      ¦   «         D ¦   «         ¦  «        }|p| j         j        S )NFz&{http://www.w3.org/1999/xhtml}fieldsetz${http://www.w3.org/1999/xhtml}legendÚdisabledc              3   ó8   •K  — | ]}|j         j        ‰k    V — Œd S r    )r!   rr   )rZ   rE   Úlegends     €r   rb   z6ElementWrapper.in_disabled_fieldset.<locals>.<genexpr>n  sJ   øè è € ð 8Bð 8Bàð Ô)Ô-°Ò7ð8Bð 8Bð 8Bð 8Bð 8Bð 8Br   )r   r!   rr   r~   rc   r@   Úin_disabled_fieldset)r'   ÚfieldsetÚdisabled_fieldsetr�   s      @r   r‘   z#ElementWrapper.in_disabled_fieldsete  sÃ   ø€ àŒ;ÐØ�5Ø;ˆØ7ˆàŒKÔ%Ô)¨XÒ5ð CØŒKÔ%×)Ò)¨*Ñ5Ô5¸TÐAðCàÔ"Ô&¨&Ò0ð BµCð 8Bð 8Bð 8Bð 8Bà#'×#>Ò#>Ñ#@Ô#@ð8Bñ 8Bô 8Bñ 5Bô 5Bð 	ð !ÐD D¤KÔ$DÐDr   r    )T)#Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úclassmethodr   r   r   r(   r-   r0   r4   r7   Úpropertyr9   r;   r>   r@   rB   rF   r6   rT   Ústaticmethodr_   re   rl   rn   r   r"   rz   ru   r}   rƒ   r…   r‘   r/   r   r   r
   r
   	   s‚  € € € € € ð
ð 
ð ðNð Nð Nñ „[ðNð$ ðMð Mð Mñ „[ðMð ðRð Rð Rñ „[ðRð 59ð'ð 'ð 'ð 'ð87ð 7ð 7ð
#ð #ð #ð6ð 6ð 6ð(ð (ð (ð ð
ð 
ñ „Xð
ð ð'ð 'ñ „Xð'ð"ð "ð "ð(*ð *ð *ð&
3ð 
3ð 
3ðð ð ðð ð ð6ð 6ð 6ð2 ð1ð 1ñ „\ð1ðDð Dð Dðð ð ð06ð 6ð 6ð ð-ð -ñ „_ð-ð ðð ñ „_ðð ðð ñ „_ðð ð,ð ,ñ „_ð,ð ðJð Jñ „_ðJð ðNð Nñ „_ðNð8 ðEð Eñ „_ðEð Eð Er   r
   c                 ó†   — |                       d¦  «        }|dk    s| d         dk    rd| fS | d|…         | |dz   d …         fS )NÚ}rM   r   Ú{r�   r   )Úrfind)rr   Úpositions     r   rw   rw   t  sO   € Ø�yŠy˜‰~Œ~€HØ�2‚~€~˜˜Qœ 3š˜Ø�3ˆwˆà�1�X�:Œ  H¨Q¡J K KÔ 0Ð0Ð0r   c                 ón   — | �.d| vr,t          | ¦  «        }t          |¦  «        dk    r|d         S d S d S d S )Nú,r   r   )r   rj   )ÚvalueÚpartss     r   r‡   r‡   |  sJ   € ØÐ˜S¨Ð-Ð-Ý  Ñ'Ô'ˆÝˆu‰:Œ:˜Š?ˆ?Ø˜”8ˆOð ÐÐ-Ð-àˆ?r   N)Ú	functoolsr   Úwarningsr   Úwebencodingsr   Úcompilerr   r   r
   rw   r‡   r/   r   r   ú<module>r¨      s´   ðØ %Ð %Ð %Ð %Ð %Ð %Ø Ð Ð Ð Ð Ð à $Ð $Ð $Ð $Ð $Ð $à =Ð =Ð =Ð =Ð =Ð =Ð =Ð =ðhEð hEð hEð hEð hEñ hEô hEð hEðV1ð 1ð 1ðð ð ð ð r   