-í
ì¶<c       sÕ     d  Z    d Z  d k Z d k Z d k Z d k Z  d k Z  d k T d k l Z  d k	 l
 Z
  d k l Z l Z  d f  d „  ƒ  YZ  e i d	 „ Z @d
 „  Z U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 0 d „  Z 3 e i d „ Z 9 d „  Z	 < d „  Z
 G d „  Z J d „  Z M d „  Z X d	 „  Z a 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    sK   % ) | 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   0 1 | |  _  d  S(   N(   s   allfiless   self(   s   selfs   allfiles(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   set_allfiles0 s   c    s   3 4 t  | ƒ |  _ d  S(   N(   s   findalls   dirs   selfs   allfiles(   s   selfs   dir(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   findall3 s   c    s   9 : 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    s0   < ? @ d k  l } A | o B | 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   G H |  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   J K |  i i | ƒ d  S(   N(   s   selfs   filess   extends   items(   s   selfs   items(    (    s(   /usr/lib/python2.2/distutils/filelist.pys   extendJ s   c    st   M O t  t i i |  i ƒ } P | i ƒ  Q g  |  _ R x3 | DR ]( } S |  i i	 t
 t i i | ƒ ƒ qA 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    sj   X Z x] t  t |  i ƒ d d d ƒ DZ ]9 } [ |  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    s~  a b t  i | ƒ } c | d } e t } } } g | d d d d f j oD i t	 | ƒ d j  o j t
 d | ‚ n m t t | d ƒ } nÕ o | d	 d
 f j oW p t	 | ƒ d j  o q t
 d | ‚ n t t | d ƒ } u t t | d ƒ } nh w | d d f j oA x t	 | ƒ d j o y 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    sñ  †  |  i | ƒ \ } } } } ’ | d j oj “ |  i d t i	 | ƒ ƒ ” xC | D” ]8 } • |  i | d d ƒo – |  i d | ƒ n qX WnS˜ | d j oj ™ |  i d t i	 | ƒ ƒ š xC | Dš ]8 } › |  i | d d ƒo œ |  i d | ƒ n qÒ WnÙ  | d	 j on ¡ |  i d
 t i	 | ƒ ƒ ¢ xG | D¢ ]< } £ |  i | d d ƒo ¤ |  i d d | ƒ n qLWn[¨ | d j on © |  i d t i	 | ƒ ƒ ª xG | Dª ]< } « |  i | d d ƒo ¬ |  i d d | ƒ n qÊWnÝ° | d j oz ± |  i d | t i	 | ƒ f ƒ ³ xM | D³ ]B } ´ |  i | d | ƒo" µ |  i d d | | f ƒ n qNWnS¹ | d j oz º |  i d | t i	 | ƒ f ƒ ¼ xM | D¼ ]B } ½ |  i | d | ƒo" ¾ |  i d d | | f ƒ n qØWnÉ Â | d j oJ Ã |  i d | ƒ Ä |  i t d | ƒo Å |  i d | ƒ n no Ç | d j oN È |  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 ù x[ |  i	 Dù ]M } ú | i | ƒ o4 û |  i d | ƒ ü |  i i | ƒ ý d } n qo 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 ƒ xy t	 t
 |  i ƒ d d d ƒ D]U } | i |  i | ƒ o5 |  i d |  i | ƒ |  i | =d } n qa 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    sT   #$d k  l }	 l } l } l } &g  } '|  g } (| i } )| i	 }
 +xî +| oã ,| ƒ  }  -t i |  ƒ } /x» | D/]° } 0|  t i j o 1t i i |  | ƒ } n
 3| } 6t i  | ƒ } 7| |	 } 8| | ƒ o 9| i	 | ƒ n0 :| | ƒ o | | ƒ o ;|
 | ƒ n q Wq[ 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;   @EFt  i |  ƒ } Ot i d d | ƒ } P| 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ä   UZ[| o5 \t |  ƒ t j o ]t i |  ƒ Sn _|  Sn a|  o bt |  ƒ } n
 dd } f| t	 j	 o: gt | ƒ d d !} hd t i i | d | ƒ } n j| o kd | } n m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   	'
ÿ  