AlkantarClanX12

Your IP : 3.144.46.90


Current Path : /proc/self/root/opt/alt/python35/lib64/python3.5/distutils/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python35/lib64/python3.5/distutils/__pycache__/filelist.cpython-35.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�