Viewing File: /opt/alt/python35/lib64/python3.5/distutils/__pycache__/filelist.cpython-35.opt-1.pyc



®ÕYfæ0ã@sÂdZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZGdd„dƒZdd	„Z
ejd
d„Zdd
„Zddddd„ZdS)zsdistutils.filelist

Provides the FileList class, used for poking about the filesystem
and building lists of files.
éN)Úconvert_path)ÚDistutilsTemplateErrorÚDistutilsInternalError)Úlogc@sÄeZdZdZdddd„Zdd„Zejdd„Zd	d
„Z	dd„Z
d
d„Zdd„Zdd„Z
dd„Zdd„Zddddd„Zddddd„ZdS)ÚFileListaÑ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)
    NcCsd|_g|_dS)N)ÚallfilesÚfiles)ÚselfÚwarnÚdebug_print©rú7/opt/alt/python35/lib64/python3.5/distutils/filelist.pyÚ__init__s	zFileList.__init__cCs
||_dS)N)r)r	rrrr
Úset_allfiles#szFileList.set_allfilescCst|ƒ|_dS)N)Úfindallr)r	Údirrrr
r&szFileList.findallcCs$ddlm}|r t|ƒdS)z~Print 'msg' to stdout if the global DEBUG (taken from the
        DISTUTILS_DEBUG environment variable) flag is true.
        r)ÚDEBUGN)Zdistutils.debugrÚprint)r	Úmsgrrrr
r)szFileList.debug_printcCs|jj|ƒdS)N)rÚappend)r	Úitemrrr
r3szFileList.appendcCs|jj|ƒdS)N)rÚextend)r	Úitemsrrr
r6szFileList.extendcCsXtttjj|jƒƒ}g|_x*|D]"}|jjtjj|Œƒq.WdS)N)ÚsortedÚmapÚosÚpathÚsplitrrÚjoin)r	Zsortable_filesZ
sort_tuplerrr
Úsort9s	
z
FileList.sortcCsVxOtt|jƒdddƒD].}|j||j|dkr |j|=q WdS)Néréÿÿÿÿ)ÚrangeÚlenr)r	Úirrr
Úremove_duplicatesCs&zFileList.remove_duplicatescCs1|jƒ}|d}d}}}|dkrrt|ƒdkrRtd|ƒ‚dd	„|d
d…Dƒ}n¯|dkrÐt|ƒd
kr td|ƒ‚t|d
ƒ}dd	„|dd…Dƒ}nQ|dkrt|ƒdkrþtd|ƒ‚t|d
ƒ}ntd|ƒ‚||||fS)NrÚincludeÚexcludeúglobal-includeúglobal-excludeéz&'%s' expects <pattern1> <pattern2> ...cSsg|]}t|ƒ‘qSr)r)Ú.0Úwrrr
ú
<listcomp>Ws	z1FileList._parse_template_line.<locals>.<listcomp>r úrecursive-includeúrecursive-excludeéz,'%s' expects <dir> <pattern1> <pattern2> ...cSsg|]}t|ƒ‘qSr)r)r+r,rrr
r-]s	ÚgraftÚprunez#'%s' expects a single <dir_pattern>zunknown action '%s')r&r'r(r))r.r/)r1r2)rr#rr)r	ÚlineZwordsÚactionÚpatternsrÚdir_patternrrr
Ú_parse_template_lineLs,
	
 
 
zFileList._parse_template_linecCs|j|ƒ\}}}}|dkrz|jddj|ƒƒx½|D]+}|j|ddƒsHtjd|ƒqHWn‡|dkrÙ|jddj|ƒƒx^|D]+}|j|ddƒs§tjd	|ƒq§Wn(|d
kr8|jddj|ƒƒxÿ|D]+}|j|ddƒstjd
|ƒqWnÉ|dkr—|jddj|ƒƒx |D]+}|j|ddƒsetjd|ƒqeWnj|dkrÿ|jd|dj|ƒfƒx;|D].}|j|d|ƒsÊtjd||ƒqÊWn|dkrg|jd|dj|ƒfƒxÓ|D].}|j|d|ƒs2tjd||ƒq2Wnš|dkr¬|jd|ƒ|jdd|ƒstjd|ƒnU|dkrñ|jd|ƒ|jdd|ƒstjd|ƒntd|ƒ‚dS)Nr&zinclude ú Úanchorr z%warning: no files found matching '%s'r'zexclude z9warning: no previously-included files found matching '%s'zglobal-includezglobal-include rz>warning: no files found matching '%s' anywhere in distributionzglobal-excludezglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionzrecursive-includezrecursive-include %s %sÚprefixz:warning: no files found matching '%s' under directory '%s'zrecursive-excludezrecursive-exclude %s %szNwarning: no previously-included files matching '%s' found under directory '%s'r1zgraft z+warning: no directories found matching '%s'r2zprune z6no previously-included directories found matching '%s'z'this cannot happen: invalid action '%s')r7rrÚinclude_patternrr
Úexclude_patternr)r	r3r4r5rr6Úpatternrrr
Úprocess_template_linehsf
	
	
	
		
		
		
	
zFileList.process_template_liner rcCs–d}t||||ƒ}|jd|jƒ|jdkrH|jƒxG|jD]<}|j|ƒrR|jd|ƒ|jj|ƒd}qRW|S)a—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.
        Fz%include_pattern: applying regex r'%s'Nz adding T)Útranslate_patternrr=rrÚsearchrr)r	r=r9r:Úis_regexÚfiles_foundÚ
pattern_reÚnamerrr
r;´s	

zFileList.include_patterncCs›d}t||||ƒ}|jd|jƒxett|jƒdddƒD]D}|j|j|ƒrO|jd|j|ƒ|j|=d}qOW|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 z
 removing Tr!r!)r?rr=r"r#rr@)r	r=r9r:rArBrCr$rrr
r<ßs	&

zFileList.exclude_pattern)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rrrÚcurdirrrrrrr%r7r>r;r<rrrr
rs


	L,rcCs5dd„tj|ddƒDƒ}ttjj|ƒS)z%
    Find all files under 'path'
    css:|]0\}}}|D]}tjj||ƒVqqdS)N)rrr)r+ÚbaseÚdirsrÚfilerrr
ú	<genexpr>ûsz#_find_all_simple.<locals>.<genexpr>ÚfollowlinksT)rÚwalkÚfilterrÚisfile)rZresultsrrr
Ú_find_all_simpleös	rRcCsOt|ƒ}|tjkrEtjtjjd|ƒ}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)	rRrrIÚ	functoolsÚpartialrÚrelpathrÚlist)rrZmake_relrrr
rs
rcCsPtj|ƒ}tj}tjdkr-d}d|}tjd||ƒ}|S)zæ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).
    ú\z\\\\z\1[^%s]z((?<!\\)(\\\\)*)\.)ÚfnmatchÚ	translaterÚsepÚreÚsub)r=rCr[Zescapedrrr
Ú
glob_to_res	
r^r cCsÑ|r&t|tƒr"tj|ƒS|S|r;t|ƒ}nd}|dk	r´tdƒ}t|ƒdt|ƒ…}tj}tjdkr”d}d|j|d|fƒ}n|rÄd|}tj|ƒS)aTranslate 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).
    ÚNrXz\\ú^z.*)	Ú
isinstanceÚstrr\Úcompiler^r#rr[r)r=r9r:rArCZ
empty_patternZ	prefix_rer[rrr
r?%s"
	 
r?)rHrr\rYrTZdistutils.utilrZdistutils.errorsrrZ	distutilsrrrRrIrr^r?rrrr
Ú<module>sè
Back to Directory File Manager