
    3 d}                         d dl Z d dlZd dlmZ d dlmZ d dlmZ  ej        e	          Z
d Zd Z	 ddZ G d	 d
e          ZdS )    NSpider)deferred_from_coro)arg_to_iterc                     t          j        |           r| S t          j        |           r+t          |           }|                    t
                     |S t          t          |                     S )N)inspect
isasyncgeniscoroutiner   addCallbackiterate_spider_outputr   )resultds     3lib/python3.11/site-packages/scrapy/utils/spider.pyr   r      si    &!! 6"" v&&	+,,,)&11222    c              #      K   ddl m} t          |                                           D ]K}t	          j        |          r5t          ||          r%|j        | j        k    rt          |dd          r|V  LdS )zReturn an iterator over all spider classes defined in the given module
    that can be instantiated (i.e. which have name)
    r   r   nameN)
scrapy.spidersr   varsvaluesr   isclass
issubclass
__module____name__getattr)moduler   objs      r   iter_spider_classesr      s       &%%%%%F||""$$  OC  	3''	 &/1	 VT**		 III r   Fc                 |   |                      |          }t          |          dk    r|                     |d                   S t          |          dk    r3|r1t                              d|d                    |          d           t          |          dk    r|rt                              dd|i           |S )a  Return a spider class that handles the given Request.

    This will look for the spiders that can handle the given request (using
    the spider loader) and return a Spider class if (and only if) there is
    only one Spider able to handle the Request.

    If multiple spiders (or no spider) are found, it will return the
    default_spidercls passed. It can optionally log if multiple or no spiders
    are found.
       r   z9More than one spider can handle: %(request)s - %(snames)sz, )requestsnamesz/Unable to find spider that handles: %(request)sr    )find_by_requestlenloadloggererrorjoin)spider_loaderr    default_spiderclslog_nonelog_multipler!   s         r   spidercls_for_requestr,   '   s     **733F
6{{a -!!&),,,
6{{Q 
< 
G499V+<+<==	
 	
 	

 6{{a 
H 
=	7?S	
 	
 	
 r   c                       e Zd ZdZdS )DefaultSpiderdefaultN)r   r   __qualname__r    r   r   r.   r.   F   s        DDDr   r.   )NFF)r   loggingr   r   scrapy.utils.deferr   scrapy.utils.miscr   	getLoggerr   r%   r   r   r,   r.   r1   r   r   <module>r6      s      ! ! ! ! ! ! 1 1 1 1 1 1 ) ) ) ) ) )		8	$	$3 3 3  & RW   >    F     r   