
    &th9                     z    d dl mZ d dlmZ d dlmZ ej        Z G d de          Z G d dej	                  Z
dS )	    )unicode_literals)xpath)ExpressionErrorc                   ,    e Zd Zd	dZd Zd Z	 d
dZdS )	XPathExpr *Fc                 >    || _         || _        || _        d | _        d S )N)pathelement	conditionpost_condition)selfr   r   r   star_prefixs        j/var/www/html/mycamper/aliexpress-site/backend/venv/lib/python3.11/site-packages/pyquery/cssselectpatch.py__init__zXPathExpr.__init__   s%    	""    c                 J    | j         r| j         d|d| _         d S || _         d S )Nz and ())r   )r   r   s     r   add_post_conditionzXPathExpr.add_post_condition   sA     	1373F3F3F3A>>#CD #1Dr   c                 b    t                               |           }| j        r|d| j        d}|S )N[])XPathExprOrig__str__r   )r   r   s     r   r   zXPathExpr.__str__   s<    $$T** 	:#ttT%8%8%89Dr   Nc                 \    t                               | ||||          }|j        | _        |S )N)closing_combinerhas_inner_condition)r   joinr   )r   combinerotherr   r   ress         r   r   zXPathExpr.join    s<      x2B5H ! J J $2
r   )r   r	   r   F)NF)__name__
__module____qualname__r   r   r   r    r   r   r   r      s_        # # # #1 1 1   9>     r   r   c                       e Zd ZdZeZd Zd Zd Zd Z	d Z
d Zd d	Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!dS )!JQueryTranslatorzThis class is used to implement the css pseudo classes
    (:first, :last, ...) that are not defined in the css standard,
    but are defined in the jquery API.
    c                 0    |                     d           |S )zMatches the first selected element::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><p class="first"></p><p></p></div>')
            >>> d('p:first')
            [<p.first>]

        ..
        zposition() = 1r   r   r   s     r   xpath_first_pseudoz#JQueryTranslator.xpath_first_pseudo4   s     	  !1222r   c                 0    |                     d           |S )zMatches the last selected element::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><p></p><p class="last"></p></div>')
            >>> d('p:last')
            [<p.last>]

        ..
        zposition() = last()r*   r+   s     r   xpath_last_pseudoz"JQueryTranslator.xpath_last_pseudoA   s     	  !6777r   c                 0    |                     d           |S )zMatches even elements, zero-indexed::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><p></p><p class="last"></p></div>')
            >>> d('p:even')
            [<p>]

        ..
        zposition() mod 2 = 1r*   r+   s     r   xpath_even_pseudoz"JQueryTranslator.xpath_even_pseudoN   s     	  !7888r   c                 0    |                     d           |S )zMatches odd elements, zero-indexed::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><p></p><p class="last"></p></div>')
            >>> d('p:odd')
            [<p.last>]

        ..
        zposition() mod 2 = 0r*   r+   s     r   xpath_odd_pseudoz!JQueryTranslator.xpath_odd_pseudo\   s     	  !7888r   c                 0    |                     d           |S )zMatches odd elements, zero-indexed::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><input checked="checked"/></div>')
            >>> d('input:checked')
            [<input>]

        ..
        z@checked and name(.) = 'input'add_conditionr+   s     r   xpath_checked_pseudoz%JQueryTranslator.xpath_checked_pseudoi   s     	<===r   c                 0    |                     d           |S )zMatches all elements that are selected::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<select><option selected="selected"/></select>')
            >>> d('option:selected')
            [<option>]

        ..
        z @selected and name(.) = 'option'r4   r+   s     r   xpath_selected_pseudoz&JQueryTranslator.xpath_selected_pseudov   s     	>???r   Tc                 &    |rdnd}d|d|d|dS )zFormat XPath condition for :disabled or :enabled pseudo-classes
        according to the WHATWG spec. See: https://html.spec.whatwg.org
        /multipage/semantics-other.html#concept-element-disabled
        r   notz(
            ((name(.) = 'button' or name(.) = 'input' or name(.) = 'select'
                    or name(.) = 'textarea' or name(.) = 'fieldset')
                and z(@disabled or (ancestor::fieldset[@disabled]
                    and not(ancestor::legend[not(preceding-sibling::legend)])))
            )
            or
            ((name(.) = 'option'
                and zr(@disabled or ancestor::optgroup[@disabled]))
            )
            or
            ((name(.) = 'optgroup' and z(@disabled)))
            )r&   )r   disabledbool_ops      r   _format_disabled_xpathz'JQueryTranslator._format_disabled_xpath   s3    
 !+""e GGWWWggg/ 	/r   c                 T    |                     |                                            |S )zMatches all elements that are disabled::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><input disabled="disabled"/></div>')
            >>> d('input:disabled')
            [<input>]

        ..
        r5   r=   r+   s     r   xpath_disabled_pseudoz&JQueryTranslator.xpath_disabled_pseudo   s)     	D7799:::r   c                 X    |                     |                     d                     |S )zMatches all elements that are enabled::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><input value="foo" /></div>')
            >>> d('input:enabled')
            [<input>]

        ..
        F)r;   r?   r+   s     r   xpath_enabled_pseudoz%JQueryTranslator.xpath_enabled_pseudo   s.     	D777GGHHHr   c                 0    |                     d           |S )zMatches all input elements of type file::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><input type="file"/></div>')
            >>> d('input:file')
            [<input>]

        ..
        z$@type = 'file' and name(.) = 'input'r4   r+   s     r   xpath_file_pseudoz"JQueryTranslator.xpath_file_pseudo        	BCCCr   c                 0    |                     d           |S )a  Matches all input elements::

            >>> from pyquery import PyQuery
            >>> d = PyQuery(('<div><input type="file"/>'
            ...              '<textarea></textarea></div>'))
            >>> d(':input')
            [<input>, <textarea>]

        ..
        zY(name(.) = 'input' or name(.) = 'select') or (name(.) = 'textarea' or name(.) = 'button')r4   r+   s     r   xpath_input_pseudoz#JQueryTranslator.xpath_input_pseudo   s+     	>	@ 	@ 	@ r   c                 0    |                     d           |S )a-  Matches all button input elements and the button element::

            >>> from pyquery import PyQuery
            >>> d = PyQuery(('<div><input type="button"/>'
            ...              '<button></button></div>'))
            >>> d(':button')
            [<input>, <button>]

        ..
        z>(@type = 'button' and name(.) = 'input') or name(.) = 'button'r4   r+   s     r   xpath_button_pseudoz$JQueryTranslator.xpath_button_pseudo   s(     	$	& 	& 	& r   c                 0    |                     d           |S )zMatches all radio input elements::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><input type="radio"/></div>')
            >>> d('input:radio')
            [<input>]

        ..
        z%@type = 'radio' and name(.) = 'input'r4   r+   s     r   xpath_radio_pseudoz#JQueryTranslator.xpath_radio_pseudo        	CDDDr   c                 0    |                     d           |S )zMatches all text input elements::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><input type="text"/></div>')
            >>> d('input:text')
            [<input>]

        ..
        z$@type = 'text' and name(.) = 'input'r4   r+   s     r   xpath_text_pseudoz"JQueryTranslator.xpath_text_pseudo   rE   r   c                 0    |                     d           |S )zMatches all checkbox input elements::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><input type="checkbox"/></div>')
            >>> d('input:checkbox')
            [<input>]

        ..
        z(@type = 'checkbox' and name(.) = 'input'r4   r+   s     r   xpath_checkbox_pseudoz&JQueryTranslator.xpath_checkbox_pseudo        	FGGGr   c                 0    |                     d           |S )zMatches all password input elements::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><input type="password"/></div>')
            >>> d('input:password')
            [<input>]

        ..
        z(@type = 'password' and name(.) = 'input'r4   r+   s     r   xpath_password_pseudoz&JQueryTranslator.xpath_password_pseudo  rQ   r   c                 0    |                     d           |S )zMatches all submit input elements::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><input type="submit"/></div>')
            >>> d('input:submit')
            [<input>]

        ..
        z&@type = 'submit' and name(.) = 'input'r4   r+   s     r   xpath_submit_pseudoz$JQueryTranslator.xpath_submit_pseudo       	DEEEr   c                 0    |                     d           |S )zMatches all hidden input elements::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><input type="hidden"/></div>')
            >>> d('input:hidden')
            [<input>]

        ..
        z&@type = 'hidden' and name(.) = 'input'r4   r+   s     r   xpath_hidden_pseudoz$JQueryTranslator.xpath_hidden_pseudo  rV   r   c                 0    |                     d           |S )zMatches all image input elements::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><input type="image"/></div>')
            >>> d('input:image')
            [<input>]

        ..
        z%@type = 'image' and name(.) = 'input'r4   r+   s     r   xpath_image_pseudoz#JQueryTranslator.xpath_image_pseudo,  rL   r   c                 0    |                     d           |S )zMatches all reset input elements::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><input type="reset"/></div>')
            >>> d('input:reset')
            [<input>]

        ..
        z%@type = 'reset' and name(.) = 'input'r4   r+   s     r   xpath_reset_pseudoz#JQueryTranslator.xpath_reset_pseudo9  rL   r   c                 0    |                     d           |S )zMatches all header elements (h1, ..., h6)::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><h1>title</h1></div>')
            >>> d(':header')
            [<h1>]

        ..
        zn(name(.) = 'h1' or name(.) = 'h2' or name (.) = 'h3') or (name(.) = 'h4' or name (.) = 'h5' or name(.) = 'h6')r4   r+   s     r   xpath_header_pseudoz$JQueryTranslator.xpath_header_pseudoF  s,     	G	I 	I 	I r   c                 0    |                     d           |S )zMatch all elements that contain other elements::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><h1><span>title</span></h1><h1/></div>')
            >>> d('h1:parent')
            [<h1>]

        ..
        zcount(child::*) > 0r4   r+   s     r   xpath_parent_pseudoz$JQueryTranslator.xpath_parent_pseudoV  s     	1222r   c                 0    |                     d           |S )zMatch all elements that do not contain other elements::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><h1><span>title</span></h1><h2/></div>')
            >>> d(':empty')
            [<h2>]

        ..
        znot(node())r4   r+   s     r   xpath_empty_pseudoz#JQueryTranslator.xpath_empty_pseudoc  s     	M***r   c                     |                                 dgk    rt          d|j                  t          |j        d         j                  }|                    d|dz   z             |S )a&  Matches a single element by its index::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><h1 class="first"/><h1 class="last"/></div>')
            >>> d('h1:eq(0)')
            [<h1.first>]
            >>> d('h1:eq(1)')
            [<h1.last>]

        ..
        NUMBERz)Expected a single integer for :eq(), got r   zposition() = %s   argument_typesr   	argumentsintvaluer   r   r   functionrj   s       r   xpath_eq_functionz"JQueryTranslator.xpath_eq_functionp  s|     ""$$
22!/&&)* * * H&q)/00  !2eai!@AAAr   c                     |                                 dgk    rt          d|j                  t          |j        d         j                  }|                    d|dz   z             |S )zMatches all elements with an index over the given one::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><h1 class="first"/><h1 class="last"/></div>')
            >>> d('h1:gt(0)')
            [<h1.last>]

        ..
        rd   )Expected a single integer for :gt(), got r   zposition() > %sre   rf   rk   s       r   xpath_gt_functionz"JQueryTranslator.xpath_gt_function  s|     ""$$
22!/&&)* * * H&q)/00  !2eai!@AAAr   c                     |                                 dgk    rt          d|j                  t          |j        d         j                  }|                    d|dz   z             |S )a  Matches all elements with an index below the given one::

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><h1 class="first"/><h1 class="last"/></div>')
            >>> d('h1:lt(1)')
            [<h1.first>]

        ..
        rd   ro   r   zposition() < %sre   rf   rk   s       r   xpath_lt_functionz"JQueryTranslator.xpath_lt_function  s|     ""$$
22!/&&)* * * H&q)/00  !2eai!@AAAr   c                     |                                 dgdgfvrt          d|j                  |                     |j        d         j                  }|                    d|z             |S )a  Matches all elements that contain the given text

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div><h1/><h1 class="title">title</h1></div>')
            >>> d('h1:contains("title")')
            [<h1.title>]

        ..
        STRINGIDENTz7Expected a single string or ident for :contains(), got r   zcontains(., %s))rg   r   rh   xpath_literalrj   r   rk   s       r   xpath_contains_functionz(JQueryTranslator.xpath_contains_function  s     ""$$hZ',CCC!/&&)* * * ""8#5a#8#>??  !2U!:;;;r   c                     |                                 dgdgfvrt          d|j                  |                     |j        d         j        d          }|                    |           |S )a  Matches elements which contain at least one element that matches
        the specified selector. https://api.jquery.com/has-selector/

            >>> from pyquery import PyQuery
            >>> d = PyQuery('<div class="foo"><div class="bar"></div></div>')
            >>> d('.foo:has(".baz")')
            []
            >>> d('.foo:has(".foo")')
            []
            >>> d('.foo:has(".bar")')
            [<div.foo>]
            >>> d('.foo:has(div)')
            [<div.foo>]

        ..
        rt   ru   z2Expected a single string or ident for :has(), got r   zdescendant::)prefix)rg   r   rh   css_to_xpathrj   r   rk   s       r   xpath_has_functionz#JQueryTranslator.xpath_has_function  s    " ""$$hZ',CCC!/&&)* * * !!q!' " 
 
 	  '''r   N)T)"r#   r$   r%   __doc__r   xpathexpr_clsr,   r.   r0   r2   r6   r8   r=   r@   rB   rD   rG   rI   rK   rN   rP   rS   rU   rX   rZ   r\   r^   r`   rb   rm   rp   rr   rw   r{   r&   r   r   r(   r(   ,   s        
 M            / / / /(                                     (  $  &  &    r   r(   N)
__future__r   	cssselectr   cssselect_xpathcssselect.xpathr   r   r   HTMLTranslatorr(   r&   r   r   <module>r      s    ( ' ' ' ' ' . . . . . . + + + + + +)       Bi i i i i5 i i i i ir   