Ñò
$8Zc           @   s½   d  Z  d Z d d k Z d d k Z d d k Z d d k Z d d k Td d k l Z d d k	 l
 Z
 l Z d d k l Z d f  d	 „  ƒ  YZ e i d
 „ Z d „  Z d e d d „ Z d S(   ss   distutils.filelist

Provides the FileList class, used for poking about the filesystem
and building lists of files.
s   $Id$iÿÿÿÿN(   t   *(   t   convert_path(   t   DistutilsTemplateErrort   DistutilsInternalError(   t   logt   FileListc           B   s˜   e  Z d  Z d d d „ Z d „  Z e i d „ Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d d d d „ Z d d d 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.

    Instance attributes:
      dir
        directory from which files will be taken -- only used if
        'allfiles' not supplied to constructor
      files
        list of filenames currently being built/filtered/manipulated
      allfiles
        complete list of files under consideration (ie. without any
        filtering applied)
    c         C   s   d  |  _ g  |  _ d  S(   N(   t   Nonet   allfilest   files(   t   selft   warnt   debug_print(    (    s(   /usr/lib/python2.6/distutils/filelist.pyt   __init__"   s    	c         C   s   | |  _  d  S(   N(   R   (   R	   R   (    (    s(   /usr/lib/python2.6/distutils/filelist.pyt   set_allfiles+   s    c         C   s   t  | ƒ |  _ d  S(   N(   t   findallR   (   R	   t   dir(    (    s(   /usr/lib/python2.6/distutils/filelist.pyR   .   s    c         C   s$   d d k  l } | o	 | GHn d S(   s~   Print 'msg' to stdout if the global DEBUG (taken from the
        DISTUTILS_DEBUG environment variable) flag is true.
        iÿÿÿÿ(   t   DEBUGN(   t   distutils.debugR   (   R	   t   msgR   (    (    s(   /usr/lib/python2.6/distutils/filelist.pyR   1   s    c         C   s   |  i  i | ƒ d  S(   N(   R   t   append(   R	   t   item(    (    s(   /usr/lib/python2.6/distutils/filelist.pyR   ;   s    c         C   s   |  i  i | ƒ d  S(   N(   R   t   extend(   R	   t   items(    (    s(   /usr/lib/python2.6/distutils/filelist.pyR   >   s    c         C   s\   t  t i i |  i ƒ } | i ƒ  g  |  _ x* | D]" } |  i i t i i | Œ  ƒ q2 Wd  S(   N(   t   mapt   ost   patht   splitR   t   sortR   t   join(   R	   t   sortable_filest
   sort_tuple(    (    s(   /usr/lib/python2.6/distutils/filelist.pyR   A   s    
	 c         C   s[   xT t  t |  i ƒ d d d ƒ D]3 } |  i | |  i | d j o |  i | =q  q  Wd  S(   Ni   i    iÿÿÿÿ(   t   ranget   lenR   (   R	   t   i(    (    s(   /usr/lib/python2.6/distutils/filelist.pyt   remove_duplicatesL   s      c         C   s)  t  i | ƒ } | d } d  } } } | d j o; t | ƒ d j  o t d | ‚ n t t | d ƒ } n« | d j oK t | ƒ d j  o t d | ‚ n t | d ƒ } t t | d ƒ } nS | d j o8 t | ƒ d j o t d | ‚ n t | d ƒ } n t d | ‚ | | | | f S(   Ni    t   includet   excludes   global-includes   global-excludei   s&   '%s' expects <pattern1> <pattern2> ...i   s   recursive-includes   recursive-excludei   s,   '%s' expects <dir> <pattern1> <pattern2> ...t   graftt   prunes#   '%s' expects a single <dir_pattern>s   unknown action '%s'(   R#   R$   s   global-includes   global-exclude(   s   recursive-includes   recursive-exclude(   R%   R&   (   t   stringR   R   R    R   R   R   (   R	   t   linet   wordst   actiont   patternsR   t   dir_pattern(    (    s(   /usr/lib/python2.6/distutils/filelist.pyt   _parse_template_lineU   s,    

c         C   sF  |  i  | ƒ \ } } } } | d j oY |  i d t i | ƒ ƒ xý| D]0 } |  i | d d ƒp t i d | ƒ qI qI WnÂ| d j oY |  i d t i | ƒ ƒ x—| D]0 } |  i | d d ƒp t i d | ƒ q¯ q¯ Wn\| d	 j o] |  i d
 t i | ƒ ƒ x1| D]4 } |  i | d d ƒp t i d d | ƒ qqWnò| d j oY |  i d t i | ƒ ƒ xÇ| D]0 } |  i | d d ƒp t i d | ƒ qqWnŒ| d j of |  i d | t i | ƒ f ƒ x[| D]7 } |  i | d | ƒp t i d d | | ƒ qëqëWn| d j ob |  i d | t i | ƒ f ƒ xè | D]3 } |  i | d | ƒp t i d | | ƒ q^q^Wnª | d j o? |  i d | ƒ |  i d  d | ƒp t i d | ƒ qBn^ | d j oC |  i d | ƒ |  i d  d | ƒp t i d d | ƒ qBn t	 d | ‚ d  S(    NR#   s   include t   anchori   s%   warning: no files found matching '%s'R$   s   exclude s9   warning: no previously-included files found matching '%s's   global-includes   global-include i    s&   warning: no files found matching '%s' s   anywhere in distributions   global-excludes   global-exclude sR   warning: no previously-included files matching '%s' found anywhere in distributions   recursive-includes   recursive-include %s %st   prefixs   under directory '%s's   recursive-excludes   recursive-exclude %s %ssN   warning: no previously-included files matching '%s' found under directory '%s'R%   s   graft s+   warning: no directories found matching '%s'R&   s   prune s)   no previously-included directories found s   matching '%s's'   this cannot happen: invalid action '%s'(
   R-   R   R'   R   t   include_patternR   R
   t   exclude_patternR   R   (   R	   R(   R*   R+   R   R,   t   pattern(    (    s(   /usr/lib/python2.6/distutils/filelist.pyt   process_template_linez   st     	 	 	 		 		 			i   i    c         C   s    d } t  | | | | ƒ } |  i d | i ƒ |  i d j o |  i ƒ  n xL |  i D]A } | i | ƒ o+ |  i d | ƒ |  i i | ƒ d } qW qW 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 1 if files are found.
        i    s%   include_pattern: applying regex r'%s's    adding i   N(	   t   translate_patternR   R2   R   R   R   t   searchR   R   (   R	   R2   R.   R/   t   is_regext   files_foundt
   pattern_ret   name(    (    s(   /usr/lib/python2.6/distutils/filelist.pyR0   É   s    	
 c         C   s    d } t  | | | | ƒ } |  i d | i ƒ xj t t |  i ƒ d d d ƒ D]I } | i |  i | ƒ o, |  i d |  i | ƒ |  i | =d } qO qO W| S(   sü   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 1 if files are found.
        i    s%   exclude_pattern: applying regex r'%s'i   iÿÿÿÿs
    removing (   R4   R   R2   R   R    R   R5   (   R	   R2   R.   R/   R6   R7   R8   R!   (    (    s(   /usr/lib/python2.6/distutils/filelist.pyR1   ÷   s    	  
N(   t   __name__t
   __module__t   __doc__R   R   R   R   t   curdirR   R   R   R   R   R"   R-   R3   R0   R1   (    (    (    s(   /usr/lib/python2.6/distutils/filelist.pyR      s   		
						%	P.c         C   s  d d k  l } l } l } l } g  } |  g } | i } | i } xÄ | o¼ | ƒ  }  t i |  ƒ }	 x |	 D]• }
 |  t i	 j o t i
 i |  |
 ƒ } n |
 } t i  | ƒ } | | } | | ƒ o | i | ƒ ql | | ƒ o | | ƒ o | | ƒ ql ql WqF W| S(   s^   Find all files under 'dir' and return the list of full filenames
    (relative to 'dir').
    iÿÿÿÿ(   t   ST_MODEt   S_ISREGt   S_ISDIRt   S_ISLNK(   t   statR>   R?   R@   RA   t   popR   R   t   listdirR=   R   R   (   R   R>   R?   R@   RA   t   listt   stackRC   t   pusht   namesR9   t   fullnameRB   t   mode(    (    s(   /usr/lib/python2.6/distutils/filelist.pyR     s*    "			 	 
c         C   s(   t  i |  ƒ } t i d 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   \1[^/](   t   fnmatcht	   translatet   ret   sub(   R2   R8   (    (    s(   /usr/lib/python2.6/distutils/filelist.pyt
   glob_to_re3  s    	i   i    c         C   sÀ   | o) t  |  ƒ t j o t i |  ƒ S|  Sn |  o t |  ƒ } n d } | d j	 oD t d ƒ } t | ƒ t | ƒ  } d t i i	 | d | ƒ } 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).
    t    t   ^s   .*N(
   t   typet
   StringTypeRM   t   compileRO   R   R    R   R   R   (   R2   R.   R/   R6   R8   t   empty_patternt	   prefix_re(    (    s(   /usr/lib/python2.6/distutils/filelist.pyR4   I  s    !(   R<   t   __revision__R   R'   RM   RK   t   typest   distutils.utilR   t   distutils.errorsR   R   t	   distutilsR   R   R=   R   RO   R   R4   (    (    (    s(   /usr/lib/python2.6/distutils/filelist.pyt   <module>   s   $
ÿ  	