
    h                          S SK r S SKJrJrJr  S SKJr  S SKJr  S\ S3r	\ R                  " \	5      R                  rS\S\\   S	S4S
 jrSS jrS\S\S	\4S jrg)    N)AnyCallableOptional)etree)HTML5_WHITESPACE[z]+fnamefuncreturnc                 D    [         R                  " S5      nUb  XU '   gX 	 g)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      X/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/parsel/xpathfuncs.pyset_xpathfuncr      s&     $$T*FuM    c                  $    [        S[        5        g )Nz	has-class)r   	has_class r   r   setupr       s    +y)r   contextclassesc                 l   U R                   R                  S5      (       dJ  U(       d  [        S5      eU H#  n[        U[        5      (       a  M  [        S5      e   SU R                   S'   U R
                  R                  S5      nUc  gSU-   S-   n[        SU5      nU H  nSU-   S-   U;  d  M    g   g)zZhas-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classF )eval_contextget
ValueError
isinstancestrcontext_nodereplace_html5_whitespaces)r   r   cnode_clsclss        r   r   r   $   s     ##N33STTAa%% !STT  04^,##''0HX~#H(h7H9s?(*  r   )r   N)retypingr   r   r   lxmlr   
w3lib.htmlr   regexcompilesubr"   r    r   r   boolr   r   r   r   <module>r.      sw    	 * *  '
R JJu-11  HX$6 4 **s c d r   