
    !h|-                    .   S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSK	J
r
JrJr  SSKJrJr  SSKJr  SSKJrJrJrJr  SSKJr  SS	KJr  \(       a   SS
K	JrJr  SSKJr  SSKJrJ r J!r!  \ " S5      r"\" S5      r#\" S5      r$\" S5      r%S-S jr&S.S jr'S/S jr(S 4S0S jjr) S1       S2S jjr* S1       S3S jjr+ S4       S5S jjr,\" S5      r-    S6S jr.\/" S5       V s1 s H  n \+" \0" U 5      5      S;  d  M  U iM     sn r1S7S jr2S8S9S jjr3S:S jr4        S;S  jr5\S<S! j5       r6\S=S" j5       r6    S>S# jr6S?S$ jr7\8" \S%5      (       a  S@S& jr9OS@S' jr9 " S( S)\\#   5      r:    SAS* jr; " S+ S,\
\#   5      r<gs  sn f )BzP
This module contains essential stuff that should've come with Python itself ;)
    )annotationsN)AsyncIteratorIterableMapping)partialwraps)chain)TYPE_CHECKINGAnyTypeVaroverload)ScrapyDeprecationWarningas_async_generator)CallableIterator)Pattern)Concatenate	ParamSpecSelf_P_T_KT_VTc                ^    [         R                  " S[        SS9  [        [	        U 5      5      $ )a  flatten(sequence) -> list

Returns a single, flat list which contains all elements retrieved
from the sequence and all recursively contained sub-sequences
(iterables).

Examples:
>>> [1, 2, [3,4], (5,6)]
[1, 2, [3, 4], (5, 6)]
>>> flatten([[[1,2,3], (42,None)], [4,5], [6], 7, (8,9,10)])
[1, 2, 3, 42, None, 4, 5, 6, 7, 8, 9, 10]
>>> flatten(["foo", "bar"])
['foo', 'bar']
>>> flatten(["foo", ["baz", 42], "bar"])
['foo', 'baz', 42, 'bar']
zUThe flatten function is deprecated and will be removed in a future version of Scrapy.   category
stacklevel)warningswarnr   listiflattenxs    Z/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/scrapy/utils/python.pyflattenr'   $   s*    " MM_)
     c              #     #    [         R                  " S[        SS9  U  H,  n[        U5      (       a  [	        U5       Sh  vN   M(  Uv   M.     g N7f)zWiflatten(sequence) -> iterator

Similar to ``.flatten()``, but returns iterator insteadzVThe iflatten function is deprecated and will be removed in a future version of Scrapy.r   r   N)r    r!   r   is_listliker#   )r%   els     r&   r#   r#   =   sF      MM`)
 r??|##H	 #s   >A AAc                ^    [        U S5      =(       a    [        U [        [        45      (       + $ )a  
>>> is_listlike("foo")
False
>>> is_listlike(5)
False
>>> is_listlike(b"foo")
False
>>> is_listlike([b"foo"])
True
>>> is_listlike((b"foo",))
True
>>> is_listlike({})
True
>>> is_listlike(set())
True
>>> is_listlike((x for x in range(3)))
True
>>> is_listlike(range(5))
True
__iter__)hasattr
isinstancestrbytesr$   s    r&   r*   r*   M   s$    * 1j!E*Qe*E&EEr(   c                    U $ N r$   s    r&   <lambda>r5   e   s    Qr(   c                    [        5       n/ nU  H4  nU" U5      nXR;   a  M  UR                  U5        UR                  U5        M6     U$ )z;efficient function to uniquify a list preserving item order)setaddappend)list_keyseenresultitemseenkeys         r&   uniquer@   e   sH    5DFd)?d  Mr(   c                    [        U [        5      (       a  U $ [        U [        [        45      (       d!  [        S[	        U 5      R
                   35      eUc  SnU R                  X5      $ )zxReturn the unicode representation of a bytes object ``text``. If
``text`` is already an unicode object, return it as-is.z3to_unicode must receive a bytes or str object, got utf-8)r/   r0   r1   	TypeErrortype__name__decodetextencodingerrorss      r&   
to_unicoderK   r   se    
 $dUCL))A$t*BUBUAVW
 	
 ;;x((r(   c                    [        U [        5      (       a  U $ [        U [        5      (       d!  [        S[	        U 5      R
                   35      eUc  SnU R                  X5      $ )zeReturn the binary representation of ``text``. If ``text``
is already a bytes object, return it as-is.z1to_bytes must receive a str or bytes object, got rB   )r/   r1   r0   rC   rD   rE   encoderG   s      r&   to_bytesrN      sa    
 $dC  ?T
@S@S?TU
 	
 ;;x((r(   c                  ^^ SUU4S jjn[        U [        5      (       a  [        R                  " U 5      n U" 5        HE  u  pE[	        U R                  U5      5      nU(       d  M(  US   R                  5       u  pxXW-   XX-   4s  $    g)a  
This function does a reverse search in a text using a regular expression
given in the attribute 'pattern'.
Since the re module does not provide this functionality, we have to find for
the expression into chunks of text extracted from the end (for the sake of efficiency).
At first, a chunk of 'chunk_size' kilobytes is extracted from the end, and searched for
the pattern. If the pattern is not found, another chunk is extracted, and another
search is performed.
This process continues until a match is found, or until the whole file is read.
In case the pattern wasn't found, None is returned, otherwise it returns a tuple containing
the start position of the match, and the ending (regarding the entire text).
c               3  f   >#    [        T5      n  U TS-  -  n U S::  a  OTU S  U 4v   M  TS4v   g 7f)N   r   )len)offset
chunk_sizerH   s    r&   _chunk_iterre_rsearch.<locals>._chunk_iter   sL     Tj4''F{=&))	 
 Qis   .1N)returnzIterable[tuple[str, int]])r/   r0   recompiler"   finditerspan)	patternrH   rT   rU   chunkrS   matchesstartends	    ``      r&   
re_rsearchrb      sz       '3**W%$w''./7 ))+JE>6<//	 '
 r(   _SelfTc                b   ^ ^ [         R                  " 5       m[        T 5      SUU 4S jj5       nU$ )zcDecorator to cache the result of a method (without arguments) using a
weak reference to its object
c                8   > U T;  a  T" U /UQ70 UD6TU '   TU    $ r3   r4   )selfargskwargscachemethods      r&   
new_method(memoizemethod_noargs.<locals>.new_method   s-    u 777E$KT{r(   )rf   rc   rg   z_P.argsrh   z	_P.kwargsrX   r   )weakrefWeakKeyDictionaryr   )rj   rk   ri   s   ` @r&   memoizemethod_noargsro      s1     4;3L3L3NE
6] 
 r(       >          	   
   c                    [        U [        5      (       d"  [        S[        U 5      R                   S35      e[        S U  5       5      $ )zvReturns ``True`` if the given ``data`` argument (a ``bytes`` object)
does not contain unprintable control characters.
zdata must be bytes, got ''c              3  2   #    U  H  o[         ;  v   M     g 7fr3   )_BINARYCHARS).0cs     r&   	<genexpr>!binary_is_text.<locals>.<genexpr>   s     3d$ds   )r/   r1   rC   rD   rE   alldatas    r&   binary_is_textr      sB     dE""3DJ4G4G3HJKK3d333r(   c                <   [        U 5      (       d"  [        S[        U 5      R                   S35      e/ n [        R
                  " U 5      n[        U [        5      (       ax  U R                  nU R                  nUR                  R                  5        HA  u  pgUR                  U;   a  M  U(       a  UR                  U;   a  M0  UR                  U5        MC     O[        UR                  5      nU(       a  U(       a  US   S:X  a  USS nU$ ! [         a    Us $ f = f)z2Return the argument name list of a callable objectzfunc must be callable, got 'rv   r   rf      N)callablerC   rD   rE   inspect	signature
ValueErrorr/   r   rg   keywords
parametersitemsnamer9   r"   )func	stripselfrg   sigpartial_args
partial_kwr   params           r&   get_func_argsr      s    D>>6tDz7J7J6K1MNND% $  yy]]
>>//1KDzz\)ejjJ6KK 2 CNN#Td1g/ABxK%  s   D DDc                   [         R                  " U 5      (       d  [         R                  " U 5      (       a  [         R                  " U 5      nOI[	        U S5      (       a!  [         R                  " U R
                  5      nO[        [        U 5       S35      eUR                  =(       d    Sn[        UR                  5      [        U5      -
  nUR                  SU n[        [        UR                  US U5      5      nXE4$ )a  Returns (args, kwargs) tuple for a function
>>> import re
>>> get_spec(re.match)
(['pattern', 'string'], {'flags': 0})

>>> class Test:
...     def __call__(self, val):
...         pass
...     def method(self, val, flags=0):
...         pass

>>> get_spec(Test)
(['self', 'val'], {})

>>> get_spec(Test.method)
(['self', 'val'], {'flags': 0})

>>> get_spec(Test().method)
(['self', 'val'], {'flags': 0})
__call__z is not callabler4   N)r   
isfunctionismethodgetfullargspecr.   r   rC   rD   defaultsrR   rg   dictzip)r   specr   firstdefaultrg   rh   s         r&   get_specr      s    , $7#3#3D#9#9%%d+	z	"	"%%dmm44:,&6788 $ 3Htyy>CM1L99]l#D#dii.9:F<r(   c                   [         R                  " S[        SS9  U(       d  g[        5       [        5       pCU HE  n[	        U5      (       a  U" U 5      U" U5      :w  a    gM)  [        XU5      [        XU5      :w  d  ME    g   g)zCompare two objects attributesz^The equal_attributes function is deprecated and will be removed in a future version of Scrapy.r   r   FT)r    r!   r   objectr   getattr)obj1obj2
attributestemp1temp2attrs         r&   equal_attributesr     su     MMh) 8VX5D>>DzT$Z' (T'74u+EE  r(   c                    g r3   r4   iterables    r&   without_none_valuesr   3  s    HKr(   c                    g r3   r4   r   s    r&   r   r   7  s    CFr(   c                    [        U [        5      (       a*  U R                  5        VVs0 s H  u  pUc  M
  X_M     snn$ [        U 5      " S U  5       5      $ s  snnf )zReturn a copy of ``iterable`` with all ``None`` entries removed.

If ``iterable`` is a mapping, return a dictionary where all pairs that have
value ``None`` have been removed.
c              3  .   #    U  H  oc  M  Uv   M     g 7fr3   r4   )ry   vs     r&   r{   &without_none_values.<locals>.<genexpr>F  s     ?X!!Xs   	)r/   r   r   rD   )r   kr   s      r&   r   r   ;  sR     (G$$!)!1C!1Q!1CC>?X??? Ds
   	AAc                8    U R                    SU R                   3$ )zReturn the full import path of the given object.

>>> from scrapy import Request
>>> global_object_name(Request)
'scrapy.http.request.Request'
>>> global_object_name(Request.replace)
'scrapy.http.request.Request.replace'
.)
__module____qualname__)objs    r&   global_object_namer   I  s!     nnQs//011r(   pypy_version_infoc                 X    [         R                  " 5         [         R                  " 5         g r3   gccollectr4   r(   r&   garbage_collectr   W  s    





r(   c                 .    [         R                  " 5         g r3   r   r4   r(   r&   r   r   ^  s    


r(   c                  @    \ rS rSrSrS	S jrS
S jrSS jrSS jrSr	g)MutableChainib  zK
Thin wrapper around itertools.chain, allowing to add iterables "in-place"
c                :    [         R                  " U5      U l        g r3   )r	   from_iterabler   rf   rg   s     r&   __init__MutableChain.__init__g  s    "'"5"5d";	r(   c                b    [        U R                  [         R                  " U5      5      U l        g r3   )r	   r   r   rf   	iterabless     r&   extendMutableChain.extendj  s    $))U%8%8%CD	r(   c                    U $ r3   r4   rf   s    r&   r-   MutableChain.__iter__m      r(   c                ,    [        U R                  5      $ r3   )nextr   r   s    r&   __next__MutableChain.__next__p  s    DIIr(   r~   N)rg   Iterable[_T])r   r   rX   None)rX   zIterator[_T]rX   r   )
rE   r   r   __firstlineno____doc__r   r   r-   r   __static_attributes__r4   r(   r&   r   r   b  s    <Er(   r   c                Z   #    U  H  n[        U5        S h  vN nU7v   M     g  N
 M&  7fr3   r   )r   itos      r&   _async_chainr   t  s-      )"- 	!G 	-s   +(&(+(+c                  @    \ rS rSrSrS	S jrS
S jrSS jrSS jrSr	g)MutableAsyncChaini|  z1
Similar to MutableChain but for async iterables
c                    [        U6 U l        g r3   r   r   r   s     r&   r   MutableAsyncChain.__init__  s    '3T':	r(   c                F    [        U R                  [        U6 5      U l        g r3   r   r   s     r&   r   MutableAsyncChain.extend  s     L),DE	r(   c                    U $ r3   r4   r   s    r&   	__aiter__MutableAsyncChain.__aiter__  r   r(   c                R   #    U R                   R                  5       I S h  vN $  N7fr3   )r   	__anext__r   s    r&   r   MutableAsyncChain.__anext__  s     YY((****s   '%'r~   N)rg    Iterable[_T] | AsyncIterator[_T])r   r   rX   r   )rX   r   r   )
rE   r   r   r   r   r   r   r   r   r   r4   r(   r&   r   r   |  s    ;F+r(   r   )r%   Iterable[Any]rX   z	list[Any])r%   r   rX   r   )r%   r   rX   bool)r:   r   r;   zCallable[[_T], Any]rX   zlist[_T])Nstrict)rH   str | bytesrI   
str | NonerJ   r0   rX   r0   )rH   r   rI   r   rJ   r0   rX   r1   )rQ   )r]   zstr | Pattern[str]rH   r0   rT   intrX   ztuple[int, int] | None)rj   %Callable[Concatenate[_SelfT, _P], _T]rX   r   )r   r1   rX   r   )F)r   Callable[..., Any]r   r   rX   z	list[str])r   r   rX   z tuple[list[str], dict[str, Any]])r   r   r   r   r   z'list[str | Callable[[Any], Any]] | NonerX   r   )r   zMapping[_KT, _VT]rX   zdict[_KT, _VT])r   Iterable[_KT]rX   r   )r   z!Mapping[_KT, _VT] | Iterable[_KT]rX   zdict[_KT, _VT] | Iterable[_KT])r   r   rX   r0   )rX   r   )r   r   rX   zAsyncIterator[_T])=r   
__future__r   r   r   rY   sysr    rm   collections.abcr   r   r   	functoolsr   r   	itertoolsr	   typingr
   r   r   r   scrapy.exceptionsr   scrapy.utils.asyncgenr   r   r   r   typing_extensionsr   r   r   r   r   r   r   r'   r#   r*   r@   rK   rN   rb   rc   ro   rangechrrx   r   r   r   r   r   r   r.   r   r   r   r   )is   0r&   <module>r      s&   # 	  	 
   < < $  8 8 6 42 ?>	4BT]enen2 F0 <G 
 CK)
)!+)<?))" CK)
)!+)<?)
)" ?C!!'*!8;!!H 
	1*$ Ry!HSV,4PPAy
4:"J
&M	2 
 K 
 K 
 F 
 F@/@#@	2 3#$$8B< $0+b) +es   0F
F