\d 2dZddlZddlZddlZddlZddlmZddlmZm Z ddl m Z GddZ dZ ejfd Zd Zd d ZdS)zsdistutils.filelist Provides the FileList class, used for poking about the filesystem and building lists of files. N convert_path)DistutilsTemplateErrorDistutilsInternalError)logcpeZdZdZddZdZejfdZdZ dZ dZ d Z d Z d Zd ZddZ ddZdS)FileListaA 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) Nc"d|_g|_dSN)allfilesfiles)selfwarn debug_prints #..\python\lib\distutils\filelist.py__init__zFileList.__init__s  c||_dSr )r )rr s r set_allfileszFileList.set_allfiles#s   rc.t||_dSr )findallr )rdirs rrzFileList.findall&s  rc8ddlm}|rt|dSdS)z~Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true. r)DEBUGN)distutils.debugrprint)rmsgrs rrzFileList.debug_print)s7 *)))))   #JJJJJ  rc:|j|dSr )r append)ritems rrzFileList.append3s $rc:|j|dSr )r extend)ritemss rr"zFileList.extend6s %     rctttjj|j}g|_|D]-}|jtjj|.dSr )sortedmapospathsplitr rjoin)rsortable_files sort_tuples rsortz FileList.sort9saBGM4: > >?? ( 9 9J J  bglJ7 8 8 8 8 9 9rctt|jdz ddD])}|j||j|dz kr|j|=*dS)Nr)rangelenr )ris rremove_duplicateszFileList.remove_duplicatesCsZs4:*Ar22 " "Az!} 1q5 111JqM " "rc|}|d}dx}x}}|dvr:t|dkrtd|zd|ddD}n|dvrOt|dkrtd |zt|d}d |ddD}nQ|d vr;t|dkrtd |zt|d}ntd |z||||fS)Nr)includeexcludeglobal-includeglobal-excludez&'%s' expects ...c,g|]}t|Sr.0ws r z1FileList._parse_template_line..W;;;A Q;;;rr/)recursive-includerecursive-excludez,'%s' expects ...c,g|]}t|Sr<rr=s rr@z1FileList._parse_template_line..]rAr)graftprunez#'%s' expects a single zunknown action '%s')r)r2rr)rlinewordsactionpatternsr dir_patterns r_parse_template_linezFileList._parse_template_lineLsV q'+++3 : : :5zzA~~,>GIII;;qrr;;;HH A A A5zzA~~,DvMOOOuQx((C;;qrr;;;HH ) ) )5zzQ,;fDFFF&uQx00KK()>)GHH H#{33rcR||\}}}}|dkr^|dd|z|D].}||dst jd|/dS|dkr^|dd|z|D].}||dst jd |/dS|d kr^|d d|z|D].}||d st jd |/dS|dkr^|dd|z|D].}||d st jd|/dS|dkrb|d|dd||D]/}|||st jd||0dS|dkrb|d|dd||D]/}|||st jd||0dS|dkrH|d|z|d|st jd|dSdS|dkrH|d|z|d|st jd|dSdStd|z)Nr6zinclude  r/)anchorz%warning: no files found matching '%s'r7zexclude z9warning: no previously-included files found matching '%s'r8zglobal-include rz>warning: no files found matching '%s' anywhere in distributionr9zglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionrBzrecursive-include )prefixz:warning: no files found matching '%s' under directory '%s'rCzrecursive-exclude zNwarning: no previously-included files matching '%s' found under directory '%s'rFzgraft z+warning: no directories found matching '%s'rGzprune z6no previously-included directories found matching '%s'z'this cannot happen: invalid action '%s')rMrr*include_patternrrexclude_patternr)rrHrJrKrrLpatterns rprocess_template_linezFileList.process_template_linehsi 04/H/H/N/N,3 Y     Z#((8*<*<< = = =# & &++GA+>>&HD$&&& & & y   Z#((8*<*<< = = =# ? ?++GA+>>?H46=??? ? ? ' ' '   .(1C1CC D D D# D D++GA+>>DH9;BDDD D D ' ' '   .(1C1CC D D D# & &++GA+>>&HD$&&& & & * * *    !cc388H#5#5#57 8 8 8# + +++GC+@@+H7$c+++ + + * * *    !cc388H#5#5#57 8 8 8# + +++GC+@@+H@$c+++ + + w     X 3 4 4 4''['AA &F$&&&&& & &w     X 3 4 4 4''['AA 9*,799999 9 9);fDFF Frr/rcDd}t||||}|d|jz|j||jD]K}||r4|d|z|j|d}L|S)aSelect 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. Fz%include_pattern: applying regex r'%s'Nz adding T)translate_patternrrTr rsearchr r)rrTrPrQis_regex files_found pattern_renames rrRzFileList.include_patterns4 &wII  @#+, - - - = LLNNNM # #D  && #  d!2333 !!$'''" rcTd}t||||}|d|jztt |jdz ddD]O}||j|r-|d|j|z|j|=d}P|S)aRemove 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. Fz%exclude_pattern: applying regex r'%s'r/r0z removing T)rWrrTr1r2r rX)rrTrPrQrYrZr[r3s rrSzFileList.exclude_patterns &wII  @#+, - - -s4:q("b11 # #A  A// #   1 !=>>>JqM" r)NNr/Nr)__name__ __module__ __qualname____doc__rrr'curdirrrrr"r-r4rMrUrRrSr<rrr r s   !!!)%%%%   !!!999"""4448GFGFGFX((((X:;rr cdtj|dD}ttjj|S)z% Find all files under 'path' c3hK|]-\}}}|D]$}tj||V%.dSr )r'r(r*)r>basedirsr files r z#_find_all_simple..sc D$   T4  rT) followlinks)r'walkfilterr(isfile)r(resultss r_find_all_simplerosE!#4!@!@!@G "'.' * **rct|}|tjkr5tjtjj|}t||}t|S)z Find all files under 'dir' and return the list of full filenames. Unless dir is '.', return full filenames with dir prepended. )start) ror'rc functoolspartialr(relpathr&list)rr make_rels rrrsR S ! !E bi$RW_C@@@He$$ ;;rctj|}tj}tjdkrd}d|z}t jd||}|S)zTranslate 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). \z\\\\z\1[^%s]z((?>CE C OOc#hh,F FG */%%CCCSSQ  F&+eeZE -D-DEJ :j ! !!rr^)rbr'r|ryrrdistutils.utilrdistutils.errorsrr distutilsrr rorcrrrWr<rrrs  ''''''KKKKKKKKbbbbbbbbP + + +    .""""""""""""r