§
    ´‚DcÂ8  ã                   óž   — d dl Z d dlmZ d dlmZ ddlmZmZ  ee d¦  «        re j	        Z	n G d„ d¦  «        Z	 G d„ d	¦  «        Z
d
„ Zd„ ZdS )é    N)Úwarn)Úascii_loweré   )Úcompile_selector_listÚsplit_whitespaceÚcached_propertyc                   ó2   — e Zd Zdd„Zd e¦   «         fd„ZdS )r   Nc                 ód   — |p|j         | _         |j        | _        |p|j        | _        || _        d S ©N)Ú__name__Ú
__module__Ú__doc__Úfunc)Úselfr   ÚnameÚdocs       ú1/usr/lib/python3/dist-packages/cssselect2/tree.pyÚ__init__zcached_property.__init__   s2   € Ø Ð1 D¤MˆDŒMØ"œoˆDŒOØÐ. $¤,ˆDŒLØˆDŒIˆIˆIó    c                 óž   — |€| S |j                              | j        |¦  «        }||u r$|                      |¦  «        }||j         | j        <   |S r   )Ú__dict__Úgetr   r   )r   ÚobjÚtypeÚ_cached_property__missingÚvalues        r   Ú__get__zcached_property.__get__   sR   € Øˆ{Ø�Ø”L×$Ò$ T¤]°IÑ>Ô>ˆEØ˜	Ð!Ð!ØŸ	š	 #™œ�Ø.3�”˜Tœ]Ñ+ØˆLr   )NN)r   r   Ú__qualname__r   Úobjectr   © r   r   r   r      sI   € € € € € ð	ð 	ð 	ð 	ð %)°F°F±H´Hð 	ð 	ð 	ð 	ð 	ð 	r   c                   óŽ  — 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      r   Úfrom_xml_rootzElementWrapper.from_xml_root-   s   € ð" �~Š~˜dÐ$4Àuˆ~ÑMÔMÐMr   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+   )Úhasattrr0   )r)   r*   r+   r%   s       r   r'   zElementWrapper._from_rootJ   sI   € å�4˜Ñ#Ô#ð 	"Ø—<’<‘>”>ˆDØˆsØ˜ Q°Ø-Ø-ð/ñ /ô /ð 	/r   c                 ó¤   — || _         || _        || _        |�|j        | _        n|g| _        || _        || _        || _        d | _        d | _	        d S r   )
Úetree_elementr1   r3   Úetree_childrenÚetree_siblingsr2   r%   Útransport_content_languageÚ
_ancestorsÚ_previous_siblings)r   r6   r1   r2   r3   r%   r+   s          r   r   zElementWrapper.__init__S   sn   € ð +ˆÔð ˆŒð !ˆŒØÐð
 #)Ô"7ˆDÔÐà#0 /ˆDÔð ˆŒ
Ø 0ˆÔØ*:ˆÔ'ð ˆŒØ"&ˆÔÐÐr   c                 ób   — t          | ¦  «        t          |¦  «        k    o| j        |j        k    S r   )r   r6   ©r   Úothers     r   Ú__eq__zElementWrapper.__eq__o   s.   € å�‰JŒJ�$˜u™+œ+Ò%ð 6ØÔ %Ô"5Ò5ð	7r   c                 ó   — | |k     S r   r    r=   s     r   Ú__ne__zElementWrapper.__ne__t   s   € Ø˜E’MÐ"Ð"r   c                 óH   — t          t          | ¦  «        | j        f¦  «        S r   )Úhashr   r6   ©r   s    r   Ú__hash__zElementWrapper.__hash__w   s   € Ý•T˜$‘Z”Z Ô!3Ð4Ñ5Ô5Ð5r   c              #   ó>   K  — |                       ¦   «         E d {V —† d S r   )Úiter_childrenrD   s    r   Ú__iter__zElementWrapper.__iter__z   s0   è è € Ø×%Ò%Ñ'Ô'Ð'Ð'Ð'Ð'Ð'Ð'Ð'Ð'Ð'r   c                 ód   — | j         €#| j        €dn| j        j        | j        fz   | _         | 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:   r1   Ú	ancestorsrD   s    r   rJ   zElementWrapper.ancestors}   s:   € ð Œ?Ð"à”kÐ)��Ø”Ô%¨¬¨Ñ6ð ŒOð ŒÐr   c                 ód   — | j         €#| j        €dn| j        j        | j        fz   | _         | 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;   r3   Úprevious_siblingsrD   s    r   rL   z ElementWrapper.previous_siblings‹   s>   € ð Ô"Ð*à”mÐ+��Ø”Ô/°4´=Ð2BÑBð Ô#ð Ô&Ð&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   ÚDeprecationWarningrJ   rD   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   rN   rL   rD   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)r1   rG   rD   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)rS   )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)r1   r2   r3   r%   )Ú	enumerater7   r   r%   )r   ÚchildÚiÚetree_childs       r   rG   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ÚappendrG   )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)r4   r   Úpseudo_elementÚnever_matchesrh   )Ú.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    )rk   rh   r   s     €r   ú	<genexpr>z)ElementWrapper.matches.<locals>.<genexpr>  s+   øè è € ÐCÐC $�4�4˜‘:”:ÐCÐCÐCÐCÐCÐCr   )Úanyrp   ©r   ro   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    )rk   rh   rd   s     €r   rs   z5ElementWrapper.query_all.<locals>.<genexpr>.<genexpr>*  s+   øè è € Ð7Ð7¨�t�t˜G‘}”}Ð7Ð7Ð7Ð7Ð7Ð7r   N)rt   )rk   rd   Útestss    @€r   rs   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    )rp   ÚlenÚfilterre   r_   )r   ro   rz   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)r`   r}   ru   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)rk   rd   s     r   rn   z1ElementWrapper.etree_children.<locals>.<listcomp>F  s:   € ð -ð -ð -ØÝ˜'œ+¥sÑ+Ô+ð-Øð-ð -ð -r   )r6   rD   s    r   r7   zElementWrapper.etree_children;  s&   € ð-ð -Ø#'Ô#5ð-ñ -ô -ð 	-r   c                 ól   — t          | j        j        ¦  «        \  }}|| j        t	          d¦  «        <   |S )z,The local name of this element, as a string.Únamespace_url©Ú_split_etree_tagr6   rƒ   r   r„   ©r   r†   Ú
local_names      r   rŠ   zElementWrapper.local_nameJ  s6   € õ %5°TÔ5GÔ5KÑ$LÔ$LÑ!ˆ�zØ.;ˆŒ•c˜/Ñ*Ô*Ñ+ØÐr   c                 ól   — t          | j        j        ¦  «        \  }}|| j        t	          d¦  «        <   |S )z/The namespace URL of this element, as a string.rŠ   r‡   r‰   s      r   r†   zElementWrapper.namespace_urlQ  s6   € õ %5°TÔ5GÔ5KÑ$LÔ$LÑ!ˆ�zØ+5ˆŒ•c˜,Ñ'Ô'Ñ(ØÐr   c                 ó6   — | j                              d¦  «        S )z$The ID of this element, as a string.Úid)r6   r   rD   s    r   r�   zElementWrapper.idX  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   r6   r   rD   s    r   ÚclasseszElementWrapper.classes]  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)
r6   r   r   r%   r†   r1   r”   r_   Ú_parse_content_languager9   )r   Úxml_langÚis_htmlr”   r+   ÚiteratorÚmetaÚ
http_equivs           r   r”   zElementWrapper.langb  sA  € ð Ô%×)Ò)Ø8ñ:ô :ˆàÐÝ˜xÑ(Ô(Ð(àÔ!ð AØÔÐ"@Ò@ð 	ð ð 	)ØÔ%×)Ò)¨&Ñ1Ô1ˆDØÐÝ" 4Ñ(Ô(Ð(ØŒ;Ð"Ø”;Ô#Ð#àð 
	5Ø#ÐØÔ)×.Ò.Ø4ñ6ô 6ˆHà ð -ð -�Ø!ŸXšX l°BÑ7Ô7�
Ý˜zÑ*Ô*Ð.@Ò@Ð@Ý'>ØŸš Ñ+Ô+ñ(-ô (-Ð$øàÐ+Ý"Ð#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   )r6   rƒ   )rk   rV   Úlegends     €r   rs   z6ElementWrapper.in_disabled_fieldset.<locals>.<genexpr>‹  sJ   øè è € ð 8Bð 8Bàð Ô)Ô-°Ò7ð8Bð 8Bð 8Bð 8Bð 8Bð 8Br   )r1   r6   rƒ   r   rt   rQ   Úin_disabled_fieldset)r   ÚfieldsetÚdisabled_fieldsetrŸ   s      @r   r    z#ElementWrapper.in_disabled_fieldset‚  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)#r   r   r   r   Úclassmethodr,   r.   r'   r   r?   rA   rE   rH   ÚpropertyrJ   rL   rO   rQ   rS   rW   rG   re   Ústaticmethodrp   rv   r}   r   r   r7   rŠ   r†   r�   r’   r”   r    r    r   r   r"   r"   !   s~  € € € € € ð
ð 
ð ðNð Nð Nñ „[ðNð$ ðMð Mð Mñ „[ðMð ð/ð /ð /ñ „[ð/ð 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ð> ðEð Eñ „_ðEð Eð Er   r"   c                 óŠ   — |                       d¦  «        }|dk    rd| fS | d         dk    sJ ‚| d|…         | |dz   d …         fS )Nú}r^   r�   r   ú{r   )Úrfind)rƒ   Úpositions     r   rˆ   rˆ   ‘  sT   € Ø�yŠy˜‰~Œ~€HØ�2‚~€~Ø�3ˆwˆà�1Œv˜Š}ˆ}ˆ}ˆ}Ø�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   r{   )r   Úpartss     r   r–   r–   š  sJ   € ØÐ˜S¨Ð-Ð-Ý  Ñ'Ô'ˆÝˆu‰:Œ:˜Š?ˆ?Ø˜”8ˆOð ÐÐ-Ð-àˆ?r   )Ú	functoolsÚwarningsr   Úwebencodingsr   Úcompilerr   r   r4   r   r"   rˆ   r–   r    r   r   ú<module>r²      sõ   ðØ Ð Ð Ð Ø Ð Ð Ð Ð Ð à $Ð $Ð $Ð $Ð $Ð $à =Ð =Ð =Ð =Ð =Ð =Ð =Ð =à
€7ˆ9Ð'Ñ(Ô(ð àÔ/€O€Oðð ð ð ð ñ ô ð ð(mEð mEð mEð mEð mEñ mEô mEð mEð`1ð 1ð 1ðð ð ð ð r   