
    3 d"                         d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d d	lmZ d
e
eef         defdZ G d de          ZdS )    N)import_module)PathLike)Path)
ModuleType)Union)BaseRunSpiderCommand)
UsageError)iter_spider_classesfilepathreturnc                    t          |                                           }|j        dvrt          d|           t	          |j                  }|gt          j        z   t          _        	 t          |j	                  }t          j        
                    d           n$# t          j        
                    d           w xY w|S )N)z.pyz.pywzNot a Python source file: r   )r   resolvesuffix
ValueErrorstrparentsyspathr   stempop)r   abspathdirnamemodules       9lib/python3.11/site-packages/scrapy/commands/runspider.py_import_filer      s    8nn$$&&G~_, A?g??@@@'.!!Gy38#CHw|,,QQMs   ,B   !Cc                   2    e Zd ZdZddiZd Zd Zd Zd ZdS )	CommandFSPIDER_LOADER_WARN_ONLYTc                     dS )Nz[options] <spider_file> selfs    r   syntaxzCommand.syntax   s    ((    c                     dS )Nz8Run a self-contained spider (without creating a project)r    r!   s    r   
short_desczCommand.short_desc"   s    IIr$   c                     dS )Nz(Run the spider defined in the given filer    r!   s    r   	long_desczCommand.long_desc%   s    99r$   c                 p   t          |          dk    rt                      t          |d                   }|                                st          d| d          	 t	          |          }n<# t
          t          f$ r(}t          dt          |          d| d          d }~ww xY wt          t          |                    }|st          d| d          |
                                } | j        j        |fi |j         | j                                         | j        j        r	d| _        d S d S )N   r   zFile not found: 
zUnable to load z: zNo spider found in file: )lenr	   r   existsr   ImportErrorr   r   listr
   r   crawler_processcrawlspargsstartbootstrap_failedexitcode)r"   argsoptsfilenamer   e	spclasses	spiderclss           r   runzCommand.run(   s\   t99> 	,,Q==   	><<<<===	I!(++FFZ( 	I 	I 	IGs8}}GG!GGGHHH	I,V4455	 	GEEEEFFFMMOO	""9<<<<<""$$$0 	DMMM	 	s   A/ /B( #B##B(N)	__name__
__module____qualname__requires_projectdefault_settingsr#   r&   r(   r<   r    r$   r   r   r      sd        148) ) )J J J: : :    r$   r   )r   	importlibr   osr   pathlibr   typesr   typingr   scrapy.commandsr   scrapy.exceptionsr	   scrapy.utils.spiderr
   r   r   r   r    r$   r   <module>rJ      s    



 # # # # # #                         0 0 0 0 0 0 ( ( ( ( ( ( 3 3 3 3 3 3
5h/ 
J 
 
 
 
! ! ! ! !" ! ! ! ! !r$   