Ñò
•èRc           @   sÉ   d  Z  d d k Z d d k Z d d k Z d d k Z d d k l Z d d k l Z d d k	 l
 Z
 d g Z e i e ƒ Z e i d e i ƒ Z e i d	 e i e i Bƒ Z d e f d
 „  ƒ  YZ d S(   su   
Class representing the list of files in a distribution.

Equivalent to distutils.filelist, but fixes some problems.
iÿÿÿÿNi   (   t   DistlibException(   t   fsdecode(   t   convert_patht   Manifests   \\w*
s   #.*?(?=
)|
(?=$)c           B   s›   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z e d „ Z	 d „  Z
 d „  Z d „  Z e d e d	 „ Z e d e d
 „ Z e d e d „ Z d „  Z RS(   s~   A list of files built by on exploring the filesystem and filtered by
    applying various patterns to what we find there.
    c         C   sZ   t  i i t  i i | p
 t  i ƒ  ƒ ƒ |  _ |  i t  i |  _ d |  _	 t
 ƒ  |  _ d S(   sd   
        Initialise an instance.

        :param base: The base directory to explore under.
        N(   t   ost   patht   abspatht   normpatht   getcwdt   baset   sept   prefixt   Nonet   allfilest   sett   files(   t   selfR	   (    (    sW   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/manifest.pyt   __init__#   s    .	c         C   s  d d k  l } l } l } g  |  _ } |  i } | g } | i } | i } x¯ | o§ | ƒ  } t i	 | ƒ }	 xˆ |	 D]€ }
 t i
 i | |
 ƒ } t i  | ƒ } | i } | | ƒ o | i t | ƒ ƒ qv | | ƒ o | | ƒ o | | ƒ qv qv WqP Wd S(   sm   Find all files under the base and set ``allfiles`` to the absolute
        pathnames of files found.
        iÿÿÿÿ(   t   S_ISREGt   S_ISDIRt   S_ISLNKN(   t   statR   R   R   R   R	   t   popt   appendR   t   listdirR   t   joint   st_modeR   (   R   R   R   R   R   t   roott   stackR   t   pusht   namest   namet   fullnameR   t   mode(    (    sW   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/manifest.pyt   findall2   s&    				 	 	c         C   sO   | i  |  i ƒ p t i i |  i | ƒ } n |  i i t i i | ƒ ƒ d S(   sz   
        Add a file to the manifest.

        :param item: The pathname to add. This can be relative to the base.
        N(	   t
   startswithR   R   R   R   R	   R   t   addR   (   R   t   item(    (    sW   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/manifest.pyR$   M   s    c         C   s"   x | D] } |  i  | ƒ q Wd S(   s†   
        Add a list of files to the manifest.

        :param items: The pathnames to add. These can be relative to the base.
        N(   R$   (   R   t   itemsR%   (    (    sW   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/manifest.pyt   add_manyW   s     c            s¤   ‡  ‡ f d †  ‰ t  ˆ  i ƒ } | oA t  ƒ  } x' | D] } ˆ | t i i | ƒ ƒ q8 W| | O} n g  } t d „  | Dƒ ƒ D] } | t i i | Œ  q„ ~ S(   s8   
        Return sorted files in directory order
        c            sn   |  i  | ƒ t i d | ƒ | ˆ  i j o= t i i | ƒ \ } } | d j p t ‚ ˆ |  | ƒ n d  S(   Ns   add_dir added %st    t   /(   R(   R)   (   R$   t   loggert   debugR	   R   R   t   splitt   AssertionError(   t   dirst   dt   parentt   _(   R   t   add_dir(    sW   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/manifest.pyR2   d   s    c         s   s%   x |  ] } t  i i | ƒ Vq Wd  S(   N(   R   R   R,   (   t   .0R   (    (    sW   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/manifest.pys	   <genexpr>s   s   	 (   R   R   R   R   t   dirnamet   sortedR   (   R   t   wantdirst   resultR.   t   ft   _[1]t
   path_tuple(    (   R   R2   sW   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/manifest.pyR5   `   s    	 c         C   s   t  ƒ  |  _ g  |  _ d S(   s   Clear all collected files.N(   R   R   R   (   R   (    (    sW   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/manifest.pyt   clearu   s    c         C   ss  |  i  | ƒ \ } } } } | d j o? xD| D]0 } |  i | d t ƒp t i d | ƒ q/ q/ Wn	| d j o? xø| D]0 } |  i | d t ƒp t i d | ƒ q{ q{ Wn½| d j o? x¬| D]0 } |  i | d t ƒp t i d | ƒ qÇ qÇ Wnq| d j o? x`| D]0 } |  i | d t ƒp t i d	 | ƒ qqWn%| d
 j oB x| D]3 } |  i | d | ƒp t i d | | ƒ q_q_WnÖ | d j oB xÅ | D]3 } |  i | d | ƒp t i d | | ƒ q®q®Wn‡ | d j o. |  i d d | ƒp t i d | ƒ qonL | d j o. |  i d d | ƒp t i d | ƒ qon t d | ƒ ‚ d S(   sv  
        Process a directive which either adds some files from ``allfiles`` to
        ``files``, or removes some files from ``files``.

        :param directive: The directive to process. This should be in a format
                     compatible with distutils ``MANIFEST.in`` files:

                     http://docs.python.org/distutils/sourcedist.html#commands
        t   includet   anchors   no files found matching %rt   excludes.   no previously-included files found matching %rs   global-includes3   no files found matching %r anywhere in distributions   global-excludesG   no previously-included files matching %r found anywhere in distributions   recursive-includeR   s-   no files found matching %r under directory %rs   recursive-excludesA   no previously-included files matching %r found under directory %rt   grafts    no directories found matching %rt   prunes4   no previously-included directories found matching %rs   invalid action %rN(	   t   _parse_directivet   _include_patternt   TrueR*   t   warningt   _exclude_patternt   FalseR   R    (   R   t	   directivet   actiont   patternst   thedirt
   dirpatternt   pattern(    (    sW   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/manifest.pyt   process_directivez   s\      	 	 	 	 			c   
   	   C   sš  | i  ƒ  } t | ƒ d j o% | d d j o | i d d ƒ n | d } d } } } | d j oV t | ƒ d j  o t d | ƒ ‚ n g  } | d D] } | t | ƒ qŸ ~ } nÌ | d j of t | ƒ d j  o t d | ƒ ‚ n t | d ƒ } g  }	 | d D] } |	 t | ƒ q~	 } nY | d j o; t | ƒ d j o t d | ƒ ‚ n t | d ƒ } n t d | ƒ ‚ | | | | f S(   sŸ   
        Validate a directive.
        :param directive: The directive to validate.
        :return: A tuple of action, patterns, thedir, dir_patterns
        i   i    R<   R>   s   global-includes   global-excludes   recursive-includes   recursive-excludeR?   R@   i   s$   %r expects <pattern1> <pattern2> ...i   s*   %r expects <dir> <pattern1> <pattern2> ...s!   %r expects a single <dir_pattern>s   unknown action %r(   s   includes   excludes   global-includes   global-excludes   recursive-includes   recursive-excludes   grafts   pruneN(   s   includes   excludes   global-includes   global-exclude(   s   recursive-includes   recursive-exclude(   s   grafts   prune(   R,   t   lent   insertR   R    R   (
   R   RG   t   wordsRH   RI   RJ   t   dir_patternR9   t   wordt   _[2](    (    sW   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/manifest.pyRA   Æ   s4     


//c         C   s~   t  } |  i | | | | ƒ } |  i d j o |  i ƒ  n x; |  i D]0 } | i | ƒ o |  i i | ƒ t } qF qF W| S(   s…  Select strings (presumably filenames) from 'self.files' that
        match 'pattern', a Unix-style wildcard (glob) pattern.

        Patterns are not quite the same as implemented by the 'fnmatch'
        module: '*' and '?'  match non-special characters, where "special"
        is platform-dependent: slash on Unix; colon, slash, and backslash on
        DOS/Windows; and colon on Mac OS.

        If 'anchor' is true (the default), then the pattern match is more
        stringent: "*.py" will match "foo.py" but not "foo/bar.py".  If
        'anchor' is false, both of these will match.

        If 'prefix' is supplied, then only filenames starting with 'prefix'
        (itself a pattern) and ending with 'pattern', with anything in between
        them, will match.  'anchor' is ignored in this case.

        If 'is_regex' is true, 'anchor' and 'prefix' are ignored, and
        'pattern' is assumed to be either a string containing a regex or a
        regex object -- no translation is done, the regex is just compiled
        and used as-is.

        Selected strings will be added to self.files.

        Return True if files are found.
        N(	   RF   t   _translate_patternR   R   R"   t   searchR   R$   RC   (   R   RL   R=   R   t   is_regext   foundt
   pattern_reR   (    (    sW   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/manifest.pyRB   ò   s    
 c         C   sf   t  } |  i | | | | ƒ } xA t |  i ƒ D]0 } | i | ƒ o |  i i | ƒ t } q. q. W| S(   st  Remove strings (presumably filenames) from 'files' that match
        'pattern'.

        Other parameters are the same as for 'include_pattern()', above.
        The list 'self.files' is modified in place. Return True if files are
        found.

        This API is public to allow e.g. exclusion of SCM subdirs, e.g. when
        packaging source distributions
        (   RF   RT   t   listR   RU   t   removeRC   (   R   RL   R=   R   RV   RW   RX   R8   (    (    sW   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/manifest.pyRE     s     c   
      C   s  | o& t  | t ƒ o t i | ƒ S| Sn | o |  i | ƒ } n d } t i t i i |  i	 d ƒ ƒ } | d j	 oq |  i d ƒ } |  i | ƒ t | ƒ  } t i }	 t i d j o
 d }	 n d | |	 i | d | f ƒ } n | o d | | } n t i | ƒ S(   s  Translate a shell-like wildcard pattern to a compiled regular
        expression.

        Return the compiled regex.  If 'is_regex' true,
        then 'pattern' is directly compiled to a regex (if it's a string)
        or just returned as-is (assumes it's a regex object).
        R(   s   \s   \\t   ^s   .*N(   t
   isinstancet   strt   ret   compilet   _glob_to_ret   escapeR   R   R   R	   R   RN   R
   (
   R   RL   R=   R   RV   RX   R	   t   empty_patternt	   prefix_reR
   (    (    sW   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/manifest.pyRT   0  s&    	!	
c         C   sU   t  i | ƒ } t i } t i d j o
 d } n d | } t i d | | ƒ } | S(   s÷   Translate a shell-like glob pattern to a regular expression.

        Return a string containing the regex.  Differs from
        'fnmatch.translate()' in that '*' does not match "special characters"
        (which are platform-specific).
        s   \s   \\\\s   \1[^%s]s   ((?<!\\)(\\\\)*)\.(   t   fnmatcht	   translateR   R
   R^   t   sub(   R   RL   RX   R
   t   escaped(    (    sW   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/manifest.pyR`   T  s    	

N(   t   __name__t
   __module__t   __doc__R   R   R"   R$   R'   RF   R5   R;   RM   RA   RC   RB   RE   RT   R`   (    (    (    sW   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/manifest.pyR      s    		
				L	,(#(   Rj   Rd   t   loggingR   R^   R(   R    t   compatR   t   utilR   t   __all__t	   getLoggerRh   R*   R_   t   Mt   _COLLAPSE_PATTERNt   St   _COMMENTED_LINEt   objectR   (    (    (    sW   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/vendor/distlib/manifest.pyt   <module>
   s   	