ž «ÿf°1c@sªdZddlZddlZddlZddlmZddlmZmZddl m Z Gdd„dƒZ ej dd „Z d d „Zd ddd d„ZdS(usdistutils.filelist Provides the FileList class, used for poking about the filesystem and building lists of files. iN(u convert_path(uDistutilsTemplateErroruDistutilsInternalError(ulogcBsÈ|EeZdZdZdddd„Zdd„Zejdd„Z dd „Z d d „Z d d „Z dd„Z dd„Zdd„Zdd„Zddddd„Zddddd„ZdS(uFileListuÑ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) cCsd|_g|_dS(N(uNoneuallfilesufiles(uselfuwarnu debug_print((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyu__init__s uFileList.__init__cCs ||_dS(N(uallfiles(uselfuallfiles((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyu set_allfiles"suFileList.set_allfilescCst|ƒ|_dS(N(ufindalluallfiles(uselfudir((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyufindall%suFileList.findallcCs'ddlm}|r#t|ƒndS(u~Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true. i(uDEBUGN(udistutils.debuguDEBUGuprint(uselfumsguDEBUG((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyu debug_print(suFileList.debug_printcCs|jj|ƒdS(N(ufilesuappend(uselfuitem((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyuappend2suFileList.appendcCs|jj|ƒdS(N(ufilesuextend(uselfuitems((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyuextend5suFileList.extendcCsXtttjj|jƒƒ}g|_x*|D]"}|jjtjj|Œƒq.WdS(N(usortedumapuosupathusplitufilesuappendujoin(uselfusortable_filesu sort_tuple((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyusort8s  u FileList.sortcCsYxRtt|jƒdddƒD]1}|j||j|dkr |j|=q q WdS(Niiiÿÿÿÿ(urangeulenufiles(uselfui((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyuremove_duplicatesBs&uFileList.remove_duplicatescCs:|jƒ}|d}d}}}|dkrut|ƒdkrUtd|ƒ‚ndd „|d d…Dƒ}nµ|dkrÖt|ƒd kr¦td|ƒ‚nt|d ƒ}dd „|dd…Dƒ}nT|dkrt|ƒdkrtd|ƒ‚nt|d ƒ}ntd|ƒ‚||||fS(Niuincludeuexcludeuglobal-includeuglobal-excludeiu&'%s' expects ...cSsg|]}t|ƒ‘qS((u convert_path(u.0uw((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyu Vs u1FileList._parse_template_line..iurecursive-includeurecursive-excludeiu,'%s' expects ...cSsg|]}t|ƒ‘qS((u convert_path(u.0uw((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyu \s ugraftupruneu#'%s' expects a single uunknown action '%s'(uincludeuexcludeuglobal-includeuglobal-exclude(urecursive-includeurecursive-exclude(ugraftuprune(usplituNoneulenuDistutilsTemplateErroru convert_path(uselfulineuwordsuactionupatternsudiru dir_pattern((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyu_parse_template_lineKs,       uFileList._parse_template_linecCs|j|ƒ\}}}}|dkr}|jddj|ƒƒxÕ|D].}|j|ddƒsHtjd|ƒqHqHWnœ|dkrß|jddj|ƒƒxs|D].}|j|ddƒsªtjd |ƒqªqªWn:|d krA|jd dj|ƒƒx|D].}|j|dd ƒs tjd |ƒq q WnØ|dkr£|jddj|ƒƒx¯|D].}|j|dd ƒsntjd|ƒqnqnWnv|dkr|jd|dj|ƒfƒxG|D]1}|j|d|ƒsÖtjd||ƒqÖqÖWn |dkry|jd|dj|ƒfƒxÜ|D]1}|j|d|ƒsAtjd||ƒqAqAWn |dkrÁ|jd|ƒ|jdd|ƒstjd|ƒqnX|dkr |jd|ƒ|jdd|ƒstjd|ƒqntd|ƒ‚dS(Nuincludeuinclude u uanchoriu%warning: no files found matching '%s'uexcludeuexclude u9warning: no previously-included files found matching '%s'uglobal-includeuglobal-include iu>warning: no files found matching '%s' anywhere in distributionuglobal-excludeuglobal-exclude uRwarning: no previously-included files matching '%s' found anywhere in distributionurecursive-includeurecursive-include %s %suprefixu:warning: no files found matching '%s' under directory '%s'urecursive-excludeurecursive-exclude %s %suNwarning: no previously-included files matching '%s' found under directory '%s'ugraftugraft u+warning: no directories found matching '%s'upruneuprune u6no previously-included directories found matching '%s'u'this cannot happen: invalid action '%s'( u_parse_template_lineu debug_printujoinuinclude_patternuloguwarnuexclude_patternuNoneuDistutilsInternalError(uselfulineuactionupatternsudiru dir_patternupattern((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyuprocess_template_linegsf                          uFileList.process_template_lineiicCsœd}t||||ƒ}|jd|jƒ|jdkrK|jƒnxJ|jD]?}|j|ƒrU|jd|ƒ|jj |ƒd}qUqUW|S(u—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, False otherwise. u%include_pattern: applying regex r'%s'u adding FNT( uFalseutranslate_patternu debug_printupatternuallfilesuNoneufindallusearchufilesuappenduTrue(uselfupatternuanchoruprefixuis_regexu files_foundu pattern_reuname((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyuinclude_pattern³s    uFileList.include_patterncCsžd}t||||ƒ}|jd|jƒxhtt|jƒdddƒD]G}|j|j|ƒrO|jd|j|ƒ|j|=d}qOqOW|S(uRemove 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, False otherwise. u%exclude_pattern: applying regex r'%s'iu removing FiÿÿÿÿiÿÿÿÿT( uFalseutranslate_patternu debug_printupatternurangeulenufilesusearchuTrue(uselfupatternuanchoruprefixuis_regexu files_foundu pattern_reui((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyuexclude_patternÞs  &  uFileList.exclude_patternN(u__name__u __module__u __qualname__u__doc__uNoneu__init__u set_allfilesuosucurdirufindallu debug_printuappenduextendusorturemove_duplicatesu_parse_template_lineuprocess_template_lineuinclude_patternuexclude_pattern(u __locals__((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyuFileList s      L,uFileListcCsddlm}m}m}m}g}|g}|j}|j}x»|r|ƒ}tj|ƒ} x–| D]Ž} |tj kr˜tj j || ƒ} n| } tj| ƒ} | |} || ƒrÓ|j| ƒqk|| ƒrk|| ƒ rk|| ƒqkqkWqFW|S(u^Find all files under 'dir' and return the list of full filenames (relative to 'dir'). i(uST_MODEuS_ISREGuS_ISDIRuS_ISLNK( ustatuST_MODEuS_ISREGuS_ISDIRuS_ISLNKupopuappenduosulistdirucurdirupathujoin(udiruST_MODEuS_ISREGuS_ISDIRuS_ISLNKulistustackupopupushunamesunameufullnameustatumode((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyufindallõs&"        ufindallcCsStj|ƒ}tj}tjdkr0d}nd|}tjd||ƒ}|S(uæ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). u\u\\\\u\1[^%s]u((?t|ƒ}nd}|dk rºtdƒ}t|ƒdt|ƒ …}tj}tjdkršd}nd|j |d|fƒ}n|rÍd|}ntj|ƒS(uTranslate 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). uNu\u\\u^u.*( u isinstanceustrureucompileu glob_to_reuNoneulenuosusepujoin(upatternuanchoruprefixuis_regexu pattern_reu empty_patternu prefix_reusep((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyutranslate_pattern+s"       utranslate_pattern(u__doc__uosureufnmatchudistutils.utilu convert_pathudistutils.errorsuDistutilsTemplateErroruDistutilsInternalErroru distutilsuloguFileListucurdirufindallu glob_to_reuNoneutranslate_pattern(((u7/opt/alt/python33/lib64/python3.3/distutils/filelist.pyus è