-í
ì¶<c       s®   d  Z  d Z d k Z d k Z d k Z d k Z d k Z d k Td k l Z d k	 l
 Z
 d k l Z 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.
s7   $Id: filelist.py,v 1.9 2001/12/06 20:51:35 fdrake Exp $N(   s   *(   s   glob(   s   convert_path(   s   DistutilsTemplateErrors   DistutilsInternalErrors   FileListc      s¡   t  Z d  Z e e d „ Z d „  Z e i d „ Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d e d d „ Z d e 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    s<   | p |  i |  _  | p |  i |  _ t |  _ g  |  _ d  S(   N(   s   warns   selfs   _FileList__warns   debug_prints   _FileList__debug_prints   Nones   allfiless   files(   s   selfs   warns   debug_print(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   __init__% s    	c    s   | |  _  d  S(   N(   s   allfiless   self(   s   selfs   allfiles(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   set_allfiles0 s    c    s   t  | ƒ |  _ d  S(   N(   s   findalls   dirs   selfs   allfiles(   s   selfs   dir(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   findall3 s    c    s   t  i i d | ƒ d  S(   Ns   warning: %s
(   s   syss   stderrs   writes   msg(   s   selfs   msg(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   __warn9 s    c    s!   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.
        (   s   DEBUGN(   s   distutils.cores   DEBUGs   msg(   s   selfs   msgs   DEBUG(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   __debug_print< s     c    s   |  i i | ƒ d  S(   N(   s   selfs   filess   appends   item(   s   selfs   item(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   appendG s    c    s   |  i i | ƒ d  S(   N(   s   selfs   filess   extends   items(   s   selfs   items(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   extendJ s    c    s_   t  t i i |  i ƒ } | i ƒ  g  |  _ x- | D]% } |  i i	 t
 t i i | ƒ ƒ q2 Wd  S(   N(   s   maps   oss   paths   splits   selfs   filess   sortable_filess   sorts
   sort_tuples   appends   applys   join(   s   selfs
   sort_tuples   sortable_files(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   sortM s    
	 c    s[   xT t  t |  i ƒ d d d ƒ D]3 } |  i | |  i | d j o |  i | =n q  Wd  S(   Ni   i    iÿÿÿÿ(   s   ranges   lens   selfs   filess   i(   s   selfs   i(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   remove_duplicatesX s      c    sE  t  i | ƒ } | d } t } } } | d d d d f j o; t	 | ƒ d j  o t
 d | ‚ n t t | d ƒ } n· | d	 d
 f j oK t	 | ƒ d j  o t
 d | ‚ n t | d ƒ } t t | d ƒ } nY | d d f j o8 t	 | ƒ d j o t
 d | ‚ n t | d ƒ } n t
 d | ‚ | | | | f Sd  S(   Ni    s   includes   excludes   global-includes   global-excludei   s&   '%s' expects <pattern1> <pattern2> ...i   s   recursive-includes   recursive-excludei   s,   '%s' expects <dir> <pattern1> <pattern2> ...s   grafts   prunes#   '%s' expects a single <dir_pattern>s   unknown action '%s'(   s   strings   splits   lines   wordss   actions   Nones   patternss   dirs   dir_patterns   lens   DistutilsTemplateErrors   maps   convert_path(   s   selfs   lines   patternss   wordss   actions   dir_patterns   dir(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   _parse_template_linea s$    
c    sd  |  i | ƒ \ } } } } | d j o[ |  i d t i	 | ƒ ƒ x: | D]2 } |  i | d d ƒo |  i d | ƒ n qI WnÞ| d j o[ |  i d t i	 | ƒ ƒ x: | D]2 } |  i | d d ƒo |  i d | ƒ n q± Wnv| d	 j o_ |  i d
 t i	 | ƒ ƒ x> | D]6 } |  i | d d ƒo |  i d d | ƒ n qWn
| d j o_ |  i d t i	 | ƒ ƒ x> | D]6 } |  i | d d ƒo |  i d d | ƒ n q…Wnž| d j ok |  i d | t i	 | ƒ f ƒ xD | D]< } |  i | d | ƒo |  i d d | | f ƒ n q÷Wn&| d j ok |  i d | t i	 | ƒ f ƒ xD | D]< } |  i | d | ƒo |  i d d | | f ƒ n qoWn® | d j oA |  i d | ƒ |  i t d | ƒo |  i d | ƒ n n` | d j oE |  i d | ƒ |  i t d | ƒo |  i d d | ƒ n n t d  | ‚ d  S(!   Ns   includes   include s   anchori   s   no files found matching '%s's   excludes   exclude s0   no previously-included files found matching '%s's   global-includes   global-include i    s   no files found matching '%s' s   anywhere in distributions   global-excludes   global-exclude s+   no previously-included files matching '%s' s   found anywhere in distributions   recursive-includes   recursive-include %s %ss   prefixs   under directory '%s's   recursive-excludes   recursive-exclude %s %ss   found under directory '%s's   grafts   graft s"   no directories found matching '%s's   prunes   prune s)   no previously-included directories found s   matching '%s's'   this cannot happen: invalid action '%s'(   s   selfs   _parse_template_lines   lines   actions   patternss   dirs   dir_patterns   debug_prints   strings   joins   patterns   include_patterns   warns   exclude_patterns   Nones   DistutilsInternalError(   s   selfs   lines   patternss   actions   patterns   dirs   dir_pattern(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   process_template_line† s\       ! !  '  'i   i    c    s¤   d } t | | | | ƒ } |  i d | i ƒ |  i	 t
 j o |  i ƒ  n xL |  i	 D]A } | i | ƒ o+ |  i d | ƒ |  i i | ƒ d } n qW W| Sd 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(   s   files_founds   translate_patterns   patterns   anchors   prefixs   is_regexs
   pattern_res   selfs   debug_prints   allfiless   Nones   findalls   names   searchs   filess   append(   s   selfs   patterns   anchors   prefixs   is_regexs   files_founds
   pattern_res   name(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   include_patternÖ s     
 c    s¤   d } t | | | | ƒ } |  i d | i ƒ xj t	 t
 |  i ƒ d d d ƒ D]I } | i |  i | ƒ o, |  i d |  i | ƒ |  i | =d } n qO W| Sd 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 N(   s   files_founds   translate_patterns   patterns   anchors   prefixs   is_regexs
   pattern_res   selfs   debug_prints   ranges   lens   filess   is   search(   s   selfs   patterns   anchors   prefixs   is_regexs   files_founds   is
   pattern_re(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   exclude_patterns       
(   s   __name__s
   __module__s   __doc__s   Nones   __init__s   set_allfiless   oss   curdirs   findalls   _FileList__warns   _FileList__debug_prints   appends   extends   sorts   remove_duplicatess   _parse_template_lines   process_template_lines   include_patterns   exclude_pattern(    (    (    s(   /usr/lib/python2.2/distutils/filelist.pys   FileList s    									%	P.c    s  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	 | ƒ n* | | ƒ o | | ƒ o |
 | ƒ n qi WqC W| Sd S(   s^   Find all files under 'dir' and return the list of full filenames
    (relative to 'dir').
    (   s   ST_MODEs   S_ISREGs   S_ISDIRs   S_ISLNKN(   s   stats   ST_MODEs   S_ISREGs   S_ISDIRs   S_ISLNKs   lists   dirs   stacks   pops   appends   pushs   oss   listdirs   namess   names   curdirs   paths   joins   fullnames   mode(   s   dirs   stats   names   S_ISLNKs   S_ISREGs   lists   pops   modes   S_ISDIRs   ST_MODEs   pushs   fullnames   stacks   names(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   findall s,     			 	 
c    s,   t  i |  ƒ } t i d d | ƒ } | Sd 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[^/]N(   s   fnmatchs	   translates   patterns
   pattern_res   res   sub(   s   patterns
   pattern_re(    (    s(   /usr/lib/python2.2/distutils/filelist.pys
   glob_to_re@s     	i   i    c    s·   | o, t |  ƒ t j o t i |  ƒ Sn |  Sn |  o t |  ƒ } n d } | t	 j	 o4 t | ƒ d d !} d t i i | d | ƒ } n | o d | } n t i | ƒ Sd 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).
    s    i    iÿÿÿÿs   ^s   .*N(   s   is_regexs   types   patterns
   StringTypes   res   compiles
   glob_to_res
   pattern_res   prefixs   Nones	   prefix_res   oss   paths   joins   anchor(   s   patterns   anchors   prefixs   is_regexs
   pattern_res	   prefix_re(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   translate_patternUs     !(   s   __doc__s   __revision__s   syss   oss   strings   res   fnmatchs   typess   globs   distutils.utils   convert_paths   distutils.errorss   DistutilsTemplateErrors   DistutilsInternalErrors   FileLists   curdirs   findalls
   glob_to_res   Nones   translate_pattern(   s   convert_paths   __revision__s   strings
   glob_to_res   translate_patterns   globs   DistutilsInternalErrors   FileLists   DistutilsTemplateErrors   syss   res   fnmatchs   oss   findall(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   ? s   $	ÿ  	