
    -Ph]+                     d   d Z ddlmZ ddlmZ ddlZddlZddlmZ ddl	m
Z
mZmZ dd	lmZmZmZmZ  e            Z e            Zej        j        ej                            d
g dg d          d                         Zej        j        d             Zej        j        ej                            dddgddg          ej                            dddgfdddgfddgfddgfdddgfgg d          ej                            de
dfedfgd d!g          d"                                                 Zej        j        ej                            de
dfedfg          d#                         Zej        j        ej                            de
dfedfg          d$                         Zd% Zd& Zej        j        ej                            de
dfedfg          d'                         Zej        j        ej                            de
dfedfg          d(                         ZdS ))z
Test the processor hooks
    )Path)TemporaryDirectoryN   )Pooch)UnzipUntar
Decompress   )pooch_test_urlpooch_test_registrycheck_tiny_datacapture_logzmethod,ext,name))autoxzN)lzmar   N)r   r   N)bzip2bz2N)gzipgzN)r   r   zdifferent-name.txt)r   r   r   r   r   name)idsc           	         t          | |          }t                      5 }t          |          }|)t          |d                    d|dg          z            }nt          ||z            }t          |t          t                    }t                      5 }|	                    d|z   |          }	|
                                }
|
                                }t          |          d	k    sJ |d
                                         d
         dk    sJ |d                             d          sJ | |d         v sJ 	 ddd           n# 1 swxY w Y   |	|k    sJ t          |	           t                      5 }|	                    d|z   |          }	|
                                dk    sJ 	 ddd           n# 1 swxY w Y   |	|k    sJ t          |	           ddd           dS # 1 swxY w Y   dS )z=Check that decompression after download works for all formats)methodr   N.tiny-data.txtdecomppathbase_urlregistryztiny-data.txt.	processorr   r   DownloadingDecompressing )r	   r   r   strjoinr   BASEURLREGISTRYr   fetchgetvalue
splitlineslensplit
startswithr   )r   extr   r"   local_storer   	true_pathpuplog_filefnamelogsliness               [/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pooch/tests/test_processors.pytest_decompressr:      s    &t444I			 K  <D388_c8,L#M#MMNNIID4K((I(CCC]] 	'hII.4	IJJE$$&&DOO%%Eu::????8>>##A&-77779''88888U2Y&&&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	!!!!]] 	-hII.4	IJJE$$&&",,,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	!!!!1                 s[   A7G,B'E?G,E	G,E	(G,;5F=1G,=G	G,G	G,,G03G0c            	         t                      5 } t          |           }t          |t          t                    }t          j        t                    5 }t          j	                    5  |
                    dt          d                     ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |j        j        d                             d          sJ d	|j        j        d         vsJ t          j        t                    5 }t          j	                    5  |
                    dt          d
                     ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |j        j        d                             d          sJ d	|j        j        d         vsJ t          j        t                    5 }t          j	                    5  |
                    dt          d                     ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |j        j        d                             d          sJ d	|j        j        d         v sJ t          j        t                    5 }t          j	                    5  |
                    dt          d                     ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |j        j        d                             d          sJ d	|j        j        d         v sJ 	 ddd           dS # 1 swxY w Y   dS )zGShould fail if method='auto' and no extension is given in the file namer   r   r   )r   r!   Nr   z"Unrecognized file extension '.txt'zpooch.Unzip/Untarblaz Invalid compression method 'bla'zipz Invalid compression method 'zip'z	store.zipz"Unrecognized file extension '.zip')r   r   r   r)   r*   pytestraises
ValueErrorwarningscatch_warningsr+   r	   valueargsr0   )r2   r   r4   	exceptions       r9   test_decompress_failsrF   E   s    
		 >K  (CCC]:&& 	P)(** P P		/Zv5N5N5N	OOOP P P P P P P P P P P P P P P	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P #A&112VWWWWW")/*>q*AAAAA]:&& 	O)(** O O		/Zu5M5M5M	NNNO O O O O O O O O O O O O O O	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O #A&112TUUUUU")/*>q*AAAAA]:&& 	O)(** O O		/Zu5M5M5M	NNNO O O O O O O O O O O O O O O	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O #A&112TUUUUU"io&:1&=====]:&& 	L)(** L L		+61J1J1J	KKKL L L L L L L L L L L L L L L	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L #A&112VWWWWW"io&:1&======3> > > > > > > > > > > > > > > > > >s6  AMB1(&BB1BB1!B"B1%M1B5	5M8B5	9AME/&&EE/EE/E E/#M/E3	3M6E3	7AMH-$&H
H-HH-HH-!M-H1	1M4H1	5AMK+"&KK+KK+KK+M+K/	/M2K/	3A MMMtarget_pathsome_custom_pathdefault_pathcustom_pathzarchive,members	tiny-datar   )storeNrL   store/tiny-data.txtstore/subdir/tiny-data.txtzstore/subdir)single_filearchive_allarchive_filearchive_subdir_filearchive_subdirarchive_multiplezprocessor_class,extensionz.zipz.tar.gzr   r   c                     | ||          }|||z   |j         z   }t                      5 }t          |          }t          ||||z  | j                  \  }}t          |t          t                    }	t                      5 }
|		                    ||z   |          }t          |          |k    sJ t          |
|           ddd           n# 1 swxY w Y   |D ]}t          |           t                      5 }
|		                    ||z   |          }t          |          |k    sJ t          |
g            ddd           n# 1 swxY w Y   |D ]}t          |           	 ddd           dS # 1 swxY w Y   dS )zGTests the behaviour of processors for unpacking archives (Untar, Unzip))membersextract_dirNr   r!   )suffixr   r   "_unpacking_expected_paths_and_logs__name__r   r)   r*   r   r+   set_check_logsr   )processor_class	extensionrG   archiverV   r"   r   
true_pathsexpected_logr4   r5   fnamesr6   s                r9   test_unpackingrc   d   sf   <  [IIII	)I,<<			 #Dzz#EWd[0/2J$
 $
 
L (CCC]] 	0hYYw2iYHHFv;;*,,,,,///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0  	# 	#EE""""]] 	&hYYw2iYHHFv;;*,,,,"%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&  	# 	#EE""""	#'# # # # # # # # # # # # # # # # # #s\   AE4A CE4C	E4C	%E4;A E;E4E	E4E	E44E8;E8c                    t                      5 }t          t          |          t          t                    } | dg          }|                    d|z   |          }t          |          dk    sJ t          |d                     | ddg          }|                    d|z   |          }t          |          d	k    sJ t          |d                    t          |d                    |                    d|z   |          }t          |          dk    sJ t          |d                    d
d
d
           d
S # 1 swxY w Y   d
S )zHTest that multiple subsequent calls to a processor yield correct resultsr   rM   rV   rL   r!   r
   r   rN   r   Nr   r   r   r)   r*   r+   r.   r   )	r]   r^   r2   r4   
processor1
filenames1
processor2
filenames2
filenames3s	            r9   test_multiple_unpackingrl      s    
		 'k**WxPPP %_.C-DEEE
YYw2jYII
:!####
1&&& %_*,HI
 
 

 YYw2jYII
:!####
1&&&
1&&& YYw2jYII
:!####
1&&&-' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 's   D&EE	Ec                 H   t                      5 }t          t          |          t          t                    } | dg          }|                    d|z   |          }t          |          dk    sJ t          |d                    ddd           dS # 1 swxY w Y   dS )	zDTest that unpack members can also be specifed both with a leading ./r   z./store/tiny-data.txtre   rL   r!   r
   r   Nrf   )r]   r^   r2   r4   rg   rh   s         r9   $test_unpack_members_with_leading_dotrn      s     
		 'k**WxPPP %_.E-FGGG
YYw2jYII
:!####
1&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 's   A;BBBc                     |                                                                  }t          |          t          |          k    sJ t          ||          D ]\  }}|                    |          sJ dS )zC
    Assert that the lines in the log match the expected ones.
    N)r,   r-   r.   r=   r0   )r5   expected_linesr8   lineexpected_lines        r9   r\   r\      s     **,,Eu::^,,,,,,"5.99 . .m}------. .    c                 X   dg}| dk    r)t          |dz            h}|                    d           n| dk    rP|Nt          |dz  dz            t          |dz  dz  dz            h}|                    | |d          d	           n| dk    r|g }|D ]}|t          |                    d
           z  }t          |                              d          s|dz  }|                    t          |                     |                    d| d           t          |          }||fS )zo
    Generate the appropriate expected paths and log message depending on the
    parameters for the test.
    r#   rK   r   zExtracting 'tiny-data.txt'rL   Nsubdirr$   zing contents/zExtracting '')r'   appendr   r/   endswithr[   )r_   rV   r   r   	log_linesr`   memberr3   s           r9   rY   rY      si   
 I+$0112
56666	G		w011w)O;<<

 	D8$r(8889999	G		 3
 	7 	7FtV\\#%6%677Iy>>**?;; 8%7	c)nn---5F5556666__
y  rs   c                    t                      5 }t          t          |          t          t                    } | dg          }|                    d|z   |          }t          |          dk    sJ  |             }|                    d|z   |          }t          |          dk    sJ 	 ddd           dS # 1 swxY w Y   dS )zx
    Test that calling with valid members then without them works.
    https://github.com/fatiando/pooch/issues/364
    r   rM   re   rL   r!   r
   Nr   r   r   r)   r*   r+   r.   r]   r^   r2   r4   rg   rh   ri   rj   s           r9   &test_unpacking_members_then_no_membersr      s    
		 #k**WxPPP %_.C-DEEE
YYw2jYII
:!#### %_&&
YYw2jYII
:"""""# # # # # # # # # # # # # # # # # #   BB<<C C c                    t                      5 }t          t          |          t          t                    } | dg          }|                    d|z   |          }t          |          dk    sJ  |             }|                    d|z   |          }t          |          dk    sJ 	 ddd           dS # 1 swxY w Y   dS )zz
    Test that calling with invalid members then without them works.
    https://github.com/fatiando/pooch/issues/364
    r   znot-a-valid-file.csvre   rL   r!   r   Nr}   r~   s           r9   ,test_unpacking_wrong_members_then_no_membersr     s    
		 #k**WxPPP %_.D-EFFF
YYw2jYII
:!#### %_&&
YYw2jYII
:"""""# # # # # # # # # # # # # # # # # #r   ) __doc__pathlibr   tempfiler   rA   r>   r&   r   
processorsr   r   r	   utilsr   r   r   r   r*   r)   marknetworkparametrizer:   rF   rc   rl   rn   r\   rY   r   r    rs   r9   <module>r      s          ' ' ' ' ' '         1 1 1 1 1 1 1 1 1 1 T T T T T T T T T T T T   
.

    	433      < > > >< D,-NM3R    	'(	()*	/01	>"#	(.9:	 	 	   & V_ui()	'   
# # '   8#8 V_ui() ' '	  
'8 V_ui() 
' 
'	  

'. . .! ! !6 V_ui() # #	  
#& V_ui() # #	  
# # #rs   