§
    ´‚Dc]  ã                   ó†   — d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	 dxZ
Z G d	„ d
¦  «        Z ej        dd¦  «        ZdS )záCSS4 selectors for Python.

cssselect2 is a straightforward implementation of CSS4 Selectors for markup
documents (HTML, XML, etc.) that can be read by ElementTree-like parsers
(including cElementTree, lxml, html5lib, etc.)

é    N)Úascii_loweré   )Úcompile_selector_list)ÚSelectorError)ÚElementWrapperz0.7.0c                   ó:   — e Zd ZdZd„ Zd„ Zd„ Zed„ ¦   «         ZdS )ÚMatcherz=A CSS selectors storage that can match against HTML elements.c                 óh   — i | _         i | _        i | _        i | _        g | _        g | _        d| _        d S )Nr   )Úid_selectorsÚclass_selectorsÚlower_local_name_selectorsÚnamespace_selectorsÚlang_attr_selectorsÚother_selectorsÚorder)Úselfs    ú5/usr/lib/python3/dist-packages/cssselect2/__init__.pyÚ__init__zMatcher.__init__   s=   € ØˆÔØ!ˆÔØ*,ˆÔ'Ø#%ˆÔ Ø#%ˆÔ Ø!ˆÔØˆŒ
ˆ
ˆ
ó    c                 óÈ  — | xj         dz  c_         |j        rdS |j        |j        | j         |j        |f}|j        �5| j                             |j        g ¦  «                             |¦  «         dS |j	        �5| j
                             |j	        g ¦  «                             |¦  «         dS |j        �5| j                             |j        g ¦  «                             |¦  «         dS |j        �5| j                             |j        g ¦  «                             |¦  «         dS |j        r| j                             |¦  «         dS | j                             |¦  «         dS )aà  Add a selector and its payload to the matcher.

        :param selector:
            A :class:`compiler.CompiledSelector` object.
        :param payload:
            Some data associated to the selector,
            such as :class:`declarations <tinycss2.ast.Declaration>`
            parsed from the :attr:`tinycss2.ast.QualifiedRule.content`
            of a style rule.
            It can be any Python object,
            and will be returned as-is by :meth:`match`.

        r   N)r   Únever_matchesÚtestÚspecificityÚpseudo_elementÚidr   Ú
setdefaultÚappendÚ
class_namer   Ú
local_namer   Úlower_local_nameÚ	namespacer   Úrequires_lang_attrr   r   )r   ÚselectorÚpayloadÚentrys       r   Úadd_selectorzMatcher.add_selector    sh  € ð 	ˆ
Œ
�a‰ˆ
Œ
àÔ!ð 	ØˆFð ŒM˜8Ô/°´ØÔ# Wð.ˆð Œ;Ð"ØÔ×(Ò(¨¬°bÑ9Ô9×@Ò@ÀÑGÔGÐGÐGÐGØÔ Ð,ØÔ ×+Ò+ØÔ# Rñ)ô )ß)/ª°©¬¨¨¨ØÔ Ð,ØÔ+×6Ò6ØÔ)¨2ñ/ô /ß/5ªv°e©}¬}¨}¨}¨}ØÔÐ+ØÔ$×/Ò/ØÔ" Bñ(ô (ß(.ª¨u©¬¨¨¨ØÔ(ð 	/ØÔ$×+Ò+¨EÑ2Ô2Ð2Ð2Ð2àÔ ×'Ò'¨Ñ.Ô.Ð.Ð.Ð.r   c                 ó–  — g }|j         �5|j         | j        v r'|                      || j        |j                  |¦  «         |j        D ]-}|| j        v r"|                      || j        |         |¦  «         Œ.t          |j        ¦  «        }|| j        v r"|                      || j        |         |¦  «         |j        | j	        v r'|                      || j	        |j                 |¦  «         d|j
        j        v r|                      || j        |¦  «         |                      || j        |¦  «         |                     t          ¬¦  «         |S )a²  Match selectors against the given element.

        :param element:
            An :class:`ElementWrapper`.
        :returns:
            A list of the payload objects associated to selectors that match
            element, in order of lowest to highest
            :attr:`compiler.CompiledSelector` specificity and in order of
            addition with :meth:`add_selector` among selectors of equal
            specificity.

        NÚlang)Úkey)r   r   Úadd_relevant_selectorsÚclassesr   r   r   r   Únamespace_urlr   Úetree_elementÚattribr   r   ÚsortÚSORT_KEY)r   ÚelementÚrelevant_selectorsr   Ú
lower_names        r   ÚmatchzMatcher.matchF   s›  € ð  ÐàŒ:Ð! g¤j°DÔ4EÐ&EÐ&EØ×'Ò'Ø˜Ô*¨7¬:Ô6Ð8JñLô Lð Lð "œ/ð 	(ð 	(ˆJØ˜TÔ1Ð1Ð1Ø×+Ò+Ø˜TÔ1°*Ô=Ø&ñ(ô (ð (øõ ! Ô!3Ñ4Ô4ˆ
Ø˜Ô8Ð8Ð8Ø×'Ò'Ø˜Ô8¸ÔDØ"ñ$ô $ð $ð Ô  DÔ$<Ð<Ð<Ø×'Ò'Ø˜Ô1°'Ô2GÔHØ"ñ$ô $ð $ð �WÔ*Ô1Ð1Ð1Ø×'Ò'Ø˜Ô1Ð3EñGô Gð Gð 	×#Ò#Ø�TÔ)Ð+=ñ	?ô 	?ð 	?ð 	×Ò¥HÐÑ-Ô-Ð-Ø!Ð!r   c                 ód   — |D ],\  }}}}} || ¦  «        r|                      ||||f¦  «         Œ-d S )N)r   )r1   Ú	selectorsr2   r   r   r   Úpseudor$   s           r   r*   zMatcher.add_relevant_selectorss   s[   € à9Bð 	;ð 	;Ñ5ˆD�+˜u f¨gØˆt�G‰}Œ}ð ;Ø"×)Ò)Ø  %¨°Ð9ñ;ô ;ð ;øð	;ð 	;r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r&   r4   Ústaticmethodr*   © r   r   r	   r	      sd   € € € € € ØGÐGðð ð ð$/ð $/ð $/ðL+"ð +"ð +"ðZ ð;ð ;ñ „\ð;ð ;ð ;r   r	   )r;   ÚoperatorÚwebencodingsr   Úcompilerr   Úparserr   Útreer   ÚVERSIONÚ__version__r	   Ú
itemgetterr0   r=   r   r   ú<module>rF      s¹   ððð ð €€€à $Ð $Ð $Ð $Ð $Ð $ð ,Ð +Ð +Ð +Ð +Ð +Ø !Ð !Ð !Ð !Ð !Ð !Ø  Ð  Ð  Ð  Ð  Ð  àÐ €ˆ+ðc;ð c;ð c;ð c;ð c;ñ c;ô c;ð c;ðL ˆ8Ô˜q !Ñ$Ô$€€€r   