
    oe                         d dl Z d dlmZmZmZ d dlmZ d dlmZ de dZ	 e j
        e	          j        Zdedee         d	dfd
ZddZdeded	efdZdS )    N)AnyCallableOptional)etree)HTML5_WHITESPACE[z]+fnamefuncreturnc                 F    t          j        d          }|||| <   dS || = dS )a  Register a custom extension function to use in XPath expressions.

    The function ``func`` registered under ``fname`` identifier will be called
    for every matching node, being passed a ``context`` parameter as well as
    any parameters passed from the corresponding XPath expression.

    If ``func`` is ``None``, the extension function will be removed.

    See more `in lxml documentation`_.

    .. _`in lxml documentation`: https://lxml.de/extensions.html#xpath-extension-functions

    N)r   FunctionNamespace)r	   r
   ns_fnss      1lib/python3.11/site-packages/parsel/xpathfuncs.pyset_xpathfuncr      s2     $T**Fu5MMM    c                  0    t          dt                     d S )Nz	has-class)r   	has_class r   r   setupr   "   s    +y)))))r   contextclassesc                 R   | j                             d          sD|st          d          |D ]&}t          |t                    st          d          'd| j         d<   | j                            d          }|dS d|z   dz   }t          d|          }|D ]}d|z   dz   |vr dS dS )	zbhas-class function.

    Return True if all ``classes`` are present in element's class attr.

    args_checkedz4XPath error: has-class must have at least 1 argumentz0XPath error: has-class arguments must be stringsTclassNF )eval_contextget
ValueError
isinstancestrcontext_nodereplace_html5_whitespaces)r   r   cnode_clsclss        r   r   r   &   s     ##N33 
4 	F    	 	Aa%%  F   04^,#''00HuX~#H(h77H  9s?(**55 +4r   )r   N)retypingr   r   r   lxmlr   
w3lib.htmlr   regexcompilesubr"   r    r   r   boolr   r   r   r   <module>r.      s    				 * * * * * * * * * *       ' ' ' ' ' ' 	!   &BJu--1  HX$6 4    ** * * *s c d      r   