
    c                     x    d dl mZmZ 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 Zd Zd	 Zd
 Zd Zd Zd ZdS )    )absolute_importprint_functionN)archiver)projectignorewith_directory_contents)FakeFrontendc                  6    d } t          dddz  i|            d S )Nc                     t                      }t          j        t          j                            | d          |          }g |j        k    sJ d |D             }t          |          h dk    sJ d S )N.projectignorec                     g | ]	}|j         
S  pattern.0r   s     Blib/python3.11/site-packages/anaconda_project/test/test_bundler.py
<listcomp>z9test_parse_ignore_file.<locals>.check.<locals>.<listcomp>       CCCw7?CCC    >   /baz#patternwithhash.foo # this comment will be part of the patternbarhellowhitespace_surrounding)r	   r   _parse_ignore_fileospathjoinerrorssetdirnamefrontendpatternspattern_stringss       r   checkz%test_parse_ignore_file.<locals>.check   s    >>.rw||GEU/V/VX`aaX_$$$$CC(CCC?## (
 (
 (
 
 	
 	
 	
 	
 	
r   r   z
# this is a sample .projectignore
   # there can be whitespace before the comment
bar
/baz
   whitespace_surrounding%s
foo # this comment will be part of the pattern
\#patternwithhash

# blank line above me

hello

        z   r   r(   s    r   test_parse_ignore_filer*      sK    

 

 

  	
  #    r   c                  D    d } t          t                      |            d S )Nc                     t                      }t          j        t          j                            | d          |          }g |j        k    sJ d |D             }|g k    sJ d S )Nr   c                     g | ]	}|j         
S r   r   r   s     r   r   zAtest_parse_missing_ignore_file.<locals>.check.<locals>.<listcomp>9   r   r   )r	   r   r   r   r   r    r!   r#   s       r   r(   z-test_parse_missing_ignore_file.<locals>.check4   sl    >>.rw||GEU/V/VX`aaX_$$$$CC(CCC"$$$$$$r   r   dictr)   s    r   test_parse_missing_ignore_filer0   3   s-    % % % DFFE*****r   c                 6      fd}t          ddi|           d S )Nc                 &   t                      }t          j                            | d          }ddlm fd}                    d|           t          j        ||          }|J d|z  g|j	        k    sJ t          j
        |d           d S )Nr   r   )openc                  h    | d                              d          rt          d           | i |S )Nr   r   NOPE)endswithIOError)argskwargs	real_opens     r   mock_codecs_openzMtest_parse_ignore_file_with_io_error.<locals>.check.<locals>.mock_codecs_openG   s?    Aw 011 2foo% y$1&111r   zcodecs.openzFailed to read %s: NOPEi  )r	   r   r   r    codecsr3   setattrr   r   r!   chmod)r$   r%   
ignorefiler;   r&   r:   monkeypatchs        @r   r(   z3test_parse_ignore_file_with_io_error.<locals>.checkA   s    >>W\\'+;<<
,,,,,,	2 	2 	2 	2 	2 	M+;<<<.z8DD)J678?JJJJ 	U#####r   r    r   )r@   r(   s   ` r   $test_parse_ignore_file_with_io_errorrB   @   s:    $ $ $ $ $* -r2E:::::r   c                  D    d } t          t                      |            d S )Nc                 <   t          j        |            t          j                            | d          }t          j                            |          sJ t                      }t          j        ||          }g |j	        k    sJ d |D             }|g dk    sJ d S )Nr   c                     g | ]	}|j         
S r   r   r   s     r   r   zAtest_parse_default_ignore_file.<locals>.check.<locals>.<listcomp>c   r   r   )z*.pycz*.pydz*.pyoz__pycache__/z.ipynb_checkpoints/z	.Trash-*/z/.spyderproject)
r   add_projectignore_if_noner   r   r    isfiler	   r   r   r!   )r$   r?   r%   r&   r'   s        r   r(   z-test_parse_default_ignore_file.<locals>.checkZ   s    /888W\\'+;<<
w~~j)))))>>.z8DDX_$$$$CC(CCC #
 #
 #
 
 	
 	
 	
 	
 	
r   r.   r)   s    r   test_parse_default_ignore_filerH   Y   s-    
 
 
 DFFE*****r   c                     G d dt                     }|                                 D ]}t          j        |          }| |         d         }| |         d         }g }g }||z   D ]n}	 |            }
t	          |
d|	           t	          |
d|           |                    |
          r|                    |	           Y|                    |	           o||k    sJ ||k    sJ d S )Nc                       e Zd ZdS ),_test_file_pattern_matcher.<locals>.FakeInfoN)__name__
__module____qualname__r   r   r   FakeInforK   m   s        r   rO   yesnounixified_relative_pathis_directory)objectkeysr   _FilePatternr=   matchesappend)testsrS   rO   pattern_stringr   should_matchshould_not_matchmatcheddid_not_matchfilenameinfos              r   _test_file_pattern_matcherra   l   s2       6     **,, 1 1'77^,U3 06%(88 	/ 	/H8::DD3X>>>D.,777t$$ /x(((($$X....w&&&&=000001 1r   c                  f    g dg ddddgg ddg g ddg g ddd} t          | d	
           d S )Nfoobar/foofoo/barr   foobarbarfoorP   rQ   rd   rf   ri   re   r   rh   )rd   ri   re   rf   r   rh   )rd   /foofoo//foo/FrS   ra   rY   s    r   )test_file_pattern_matcher_non_directoriesrr      s     100---
 

 9%888
 

 JJJ
 

 JJJ
 
 E& u5999999r   c                  z    g dg ddddgg ddd} | d         | d<   | d	         | d
<   t          | d           d S )Nrc   rg   rj   rd   rf   rk   )rd   rl   rm   rl   rn   Tro   rp   rq   s    r   *test_file_pattern_matcher_with_directoriesrt      s~     100---
 

 9%888
 
	 	E %LE&M6]E'Nu4888888r   )
__future__r   r   r   anaconda_projectr   r   ,anaconda_project.internal.test.tmpfile_utilsr   ,anaconda_project.internal.test.fake_frontendr	   r*   r0   rB   rH   ra   rr   rt   r   r   r   <module>ry      s    7 6 6 6 6 6 6 6 				 % % % % % % * * * * * * P P P P P P E E E E E E  B
+ 
+ 
+; ; ;2+ + +&1 1 1,: : :.9 9 9 9 9r   