
    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mZ  G d	 d
e          Z G d de          ZdS )    N)defaultdict)TextTestResult)TextTestRunner)ScrapyCommand)ContractsManager)build_component_list)load_objectset_environc                       e Zd Zd ZdS )r   c           	      *   | j         j        }| j         j        }| j        }|dk    rdnd} || j                    |d| d| d||z
  dd            |             g }|                                 sd |d           t          t          | j        | j	        f          \  }}	|r|
                    d	|            |	r|
                    d
|	            n |d           |r$ |dd                    |           d           d S  |d           d S )N   s zRan z	 contractz in z.3fFAILEDz	failures=zerrors=OKz (z, )
)streamwritewritelntestsRun
separator2wasSuccessfulmaplenfailureserrorsappendjoin)
selfstartstopr   r   runpluralinfosfailederroreds
             5lib/python3.11/site-packages/scrapy/commands/check.pyprintSummaryzTextTestResult.printSummary   s\   !+%mq(b   DsDDVDDDDDDEEE			!!## 	E(OOO!#t{'CDDOFG 3111222 20w00111E$KKK 	G,5)),,,-----E$KKKKK    N)__name__
__module____qualname__r)    r*   r(   r   r      s#            r*   r   c                   2    e Zd ZdZddiZd Zd Zd Zd ZdS )	CommandTLOG_ENABLEDFc                     dS )Nz[options] <spider>r.   r    s    r(   syntaxzCommand.syntax-   s    ##r*   c                     dS )NzCheck spider contractsr.   r3   s    r(   
short_desczCommand.short_desc0   s    ''r*   c                     t          j        | |           |                    ddddd           |                    ddd	d
dd           d S )Nz-lz--listlist
store_truez*only list contracts, without checking them)destactionhelpz-vz	--verboseverboseFz$print contract tests for all spiders)r:   defaultr;   r<   )r   add_optionsadd_argument)r    parsers     r(   r?   zCommand.add_options3   s|    !$///= 	 	
 	
 	
 	7 	 	
 	
 	
 	
 	
r*   c                    t          | j                            d                    }t          d |D                       t	          |j        rdnd          }t          |j        |j        |j	                  t          t                    }| j        j        }t          d          5  |p|                                D ]}|                    |          }fd|_                            |          }	|j        r&|	D ]"}
||j                                     |
           #d|	r| j                            |           |j        ret+          |                                          D ]B\  }}|s|j        st/          |           t+          |          D ]}
t/          d	|
            Cnt1          j                    }| j                                         t1          j                    }                                                     ||           t9                                                     | _        d d d            d S # 1 swxY w Y   d S )
NSPIDER_CONTRACTSc              3   4   K   | ]}t          |          V  d S N)r	   ).0cs     r(   	<genexpr>zCommand.run.<locals>.<genexpr>H   s(      !D!DQ+a..!D!D!D!D!D!Dr*      r   )	verbositytrue)SCRAPY_CHECKc                 0                         |           S rE   )from_spider)r   conmanresults    r(   <lambda>zCommand.run.<locals>.<lambda>T   s    V5G5G65R5R r*   z  * )r   settingsgetwithbaser   r   r=   r   r   descriptionsrJ   r   r8   crawler_processspider_loaderr
   loadstart_requeststested_methods_from_spiderclsnamer   crawlsorteditemsprinttimer!   printErrorsr)   intr   exitcode)r    argsopts	contractsrunnercontract_reqsrV   
spidername	spiderclstested_methodsmethodspidermethodsr!   r"   rO   rP   s                  @@r(   r#   zCommand.runE   s   ()B)BCU)V)VWW	!!D!D)!D!D!DDDt|*B!!CCCv/BFDTUU $D)),:f--- 	@ 	@":m&8&8&:&: 	: 	:
)..z::	+R+R+R+R+R	(!'!E!Ei!P!P9 :"0 E E%in5<<VDDDDE# :(..y999 y @'-m.A.A.C.C'D'D / /OFG" !4< ! &MMM"(// / /oVoo..../	/ 	$**,,,y{{""$$$##E4000 #(<(<(>(>$> ? ?7	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@s   ,FIIIN)	r+   r,   r-   requires_projectdefault_settingsr4   r6   r?   r#   r.   r*   r(   r0   r0   )   sf        %u-$ $ $( ( (
 
 
$'@ '@ '@ '@ '@r*   r0   )r_   collectionsr   unittestr   _TextTestResultr   scrapy.commandsr   scrapy.contractsr   scrapy.utils.confr   scrapy.utils.miscr	   r
   r0   r.   r*   r(   <module>rw      s    # # # # # # 6 6 6 6 6 6 # # # # # # ) ) ) ) ) ) - - - - - - 2 2 2 2 2 2 6 6 6 6 6 6 6 6    _   :C@ C@ C@ C@ C@m C@ C@ C@ C@ C@r*   