ó
¼S]c           @@ s¥   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(   i    (   t   absolute_importt   print_functionN(   t   archiver(   t   project_ops(   t   with_directory_contents(   t   FakeFrontendc          C@ s%   d „  }  t  i d d d 6|  ƒ d  S(   Nc         S@ sƒ   t  ƒ  } t j t j j |  d ƒ | ƒ } g  | j k s? t ‚ g  | D] } | j ^ qF } | d d d d d d g k s t ‚ d  S(   Ns   .projectignoret   bars   /bazt   whitespace_surroundings.   foo # this comment will be part of the patterns   #patternwithhasht   hello(	   R   R   t   _parse_ignore_filet   ost   patht   joint   errorst   AssertionErrort   pattern(   t   dirnamet   frontendt   patternsR   t   pattern_strings(    (    sA   lib/python2.7/site-packages/anaconda_project/test/test_bundler.pyt   check   s    	!sà   
# 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

        s      s   .projectignore(   R   (   R   (    (    sA   lib/python2.7/site-packages/anaconda_project/test/test_bundler.pyt   test_parse_ignore_file   s    	c          C@ s   d „  }  t  t ƒ  |  ƒ d  S(   Nc         S@ sq   t  ƒ  } t j t j j |  d ƒ | ƒ } g  | j k s? t ‚ g  | D] } | j ^ qF } | g  k sm t ‚ d  S(   Ns   .projectignore(	   R   R   R	   R
   R   R   R   R   R   (   R   R   R   R   R   (    (    sA   lib/python2.7/site-packages/anaconda_project/test/test_bundler.pyR   3   s
    	!(   R   t   dict(   R   (    (    sA   lib/python2.7/site-packages/anaconda_project/test/test_bundler.pyt   test_parse_missing_ignore_file2   s    		c         @ s'   ‡  f d †  } t  i d d 6| ƒ d  S(   Nc         @ s¡   t  ƒ  } t j j |  d ƒ } d d l m ‰  ‡  f d †  } ˆ j d | ƒ t j | | ƒ } | d  k sq t
 ‚ d | g | j k s t
 ‚ t j | d ƒ d  S(   Ns   .projectignorei    (   t   openc          @ s3   |  d j  d ƒ r" t d ƒ ‚ n ˆ  |  | Ž  Sd  S(   Ni    s   .projectignoret   NOPE(   t   endswitht   IOError(   t   argst   kwargs(   t	   real_open(    sA   lib/python2.7/site-packages/anaconda_project/test/test_bundler.pyt   mock_codecs_openF   s    s   codecs.opens   Failed to read %s: NOPEiÿ  (   R   R
   R   R   t   codecsR   t   setattrR   R	   t   NoneR   R   t   chmod(   R   R   t
   ignorefileR   R   (   t   monkeypatch(   R   sA   lib/python2.7/site-packages/anaconda_project/test/test_bundler.pyR   @   s    	t    s   .projectignore(   R   (   R%   R   (    (   R%   sA   lib/python2.7/site-packages/anaconda_project/test/test_bundler.pyt$   test_parse_ignore_file_with_io_error?   s    c          C@ s   d „  }  t  t ƒ  |  ƒ d  S(   Nc         S@ s±   t  j |  ƒ t j j |  d ƒ } t j j | ƒ s: t ‚ t ƒ  } t j	 | | ƒ } g  | j
 k sj t ‚ g  | D] } | j ^ qq } | d d d d d d d g k s­ t ‚ d  S(	   Ns   .projectignores   /anaconda-project-local.ymls   __pycache__/s   *.pycs   *.pyos   *.pyds   .ipynb_checkpoints/s   /.spyderproject(   R   t   _add_projectignore_if_noneR
   R   R   t   isfileR   R   R   R	   R   R   (   R   R$   R   R   R   R   (    (    sA   lib/python2.7/site-packages/anaconda_project/test/test_bundler.pyR   Y   s    	(   R   R   (   R   (    (    sA   lib/python2.7/site-packages/anaconda_project/test/test_bundler.pyt   test_parse_default_ignore_fileX   s    	c         C@ sö   d t  f d „  ƒ  Y} xÙ |  j ƒ  D]Ë } t j | ƒ } |  | d } |  | d } g  } g  } xg | | D][ }	 | ƒ  }
 t |
 d |	 ƒ t |
 d | ƒ | j |
 ƒ r¹ | j |	 ƒ qk | j |	 ƒ qk W| | k sÜ t ‚ | | k s# t ‚ q# Wd  S(   Nt   FakeInfoc           B@ s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sA   lib/python2.7/site-packages/anaconda_project/test/test_bundler.pyR+   m   s   t   yest   not   unixified_relative_patht   is_directory(   t   objectt   keysR   t   _FilePatternR!   t   matchest   appendR   (   t   testsR1   R+   t   pattern_stringR   t   should_matcht   should_not_matcht   matchedt   did_not_matcht   filenamet   info(    (    sA   lib/python2.7/site-packages/anaconda_project/test/test_bundler.pyt   _test_file_pattern_matcherl   s     	c          C@ s¶   i i d d d g d 6d d d g d 6d 6i d d g d 6d d d d g d 6d	 6i g  d 6d d d d d d g d 6d
 6i g  d 6d d d d d d g d 6d 6}  t  |  d t ƒd  S(   Nt   foos   bar/foos   foo/barR.   R   t   foobart   barfooR/   s   /foos   foo/s   /foo/R1   (   R?   t   False(   R7   (    (    sA   lib/python2.7/site-packages/anaconda_project/test/test_bundler.pyt)   test_file_pattern_matcher_non_directories‚   s     c          C@ s„   i i d d d g d 6d d d g d 6d 6i d d g d 6d d d d g d 6d	 6}  |  d |  d
 <|  d	 |  d <t  |  d t ƒd  S(   NR@   s   bar/foos   foo/barR.   R   RA   RB   R/   s   /foos   foo/s   /foo/R1   (   R?   t   True(   R7   (    (    sA   lib/python2.7/site-packages/anaconda_project/test/test_bundler.pyt*   test_file_pattern_matcher_with_directories™   s    (   t
   __future__R    R   R
   t   anaconda_projectR   R   t,   anaconda_project.internal.test.tmpfile_utilsR   t,   anaconda_project.internal.test.fake_frontendR   R   R   R'   R*   R?   RD   RF   (    (    (    sA   lib/python2.7/site-packages/anaconda_project/test/test_bundler.pyt   <module>   s   	 					