관리-도구
편집 파일: filelist.cpython-39.pyc
a �����DOg 2����������������������@���s����d�Z�ddlZddlZddlZddlZddlmZ�ddlmZm Z �ddl mZ�G�dd��d�Zdd ��Z ejfd d�Zdd ��Zddd�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|���e�Zd�ZdZddd�Zdd��Zejfdd�Zd d ��Z dd��Z d d��Zdd��Zdd��Z dd��Zdd��Zddd�Zddd�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) Nc�����������������C���s���d�|�_�g�|�_d�S��N)�allfiles�files)�self�warn�debug_print��r����*/usr/lib64/python3.9/distutils/filelist.py�__init__���s����zFileList.__init__c�����������������C���s ���||�_�d�S�r���)r ���)r���r ���r���r���r����set_allfiles#���s����zFileList.set_allfilesc�����������������C���s���t�|�|�_d�S�r���)�findallr ���)r����dirr���r���r���r���&���s����zFileList.findallc�����������������C���s���ddl�m}�|rt|��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����msgr���r���r���r���r ���)���s����zFileList.debug_printc�����������������C���s���|�j��|��d�S�r���)r ����append)r����itemr���r���r���r���3���s����zFileList.appendc�����������������C���s���|�j��|��d�S�r���)r ����extend)r����itemsr���r���r���r���6���s����zFileList.extendc�����������������C���s<���t�ttjj|�j��}g�|�_|D�]}|�j�tjj|����qd�S�r���)�sorted�map�os�path�splitr ���r����join)r���Zsortable_filesZ sort_tupler���r���r����sort9���s����z FileList.sortc�����������������C���s@���t�t|�j�d�dd�D�]$}|�j|�|�j|d��kr|�j|=�qd�S�)N����r������)�range�lenr ���)r����ir���r���r����remove_duplicatesC���s����zFileList.remove_duplicatesc�����������������C���s����|����}|d�}d��}�}}|dv�rTt|�dk�r<td|���dd��|dd���D��}n~|dv�r�t|�d k�rttd |���t|d��}dd��|dd���D��}n:|dv�r�t|�dkr�td |���t|d��}ntd|���||||fS�)Nr���)�include�exclude�global-include�global-exclude����z&'%s' expects <pattern1> <pattern2> ...c�����������������S���s���g�|�]}t�|��qS�r���r�����.0�wr���r���r���� <listcomp>W��������z1FileList._parse_template_line.<locals>.<listcomp>r"���)�recursive-include�recursive-exclude����z,'%s' expects <dir> <pattern1> <pattern2> ...c�����������������S���s���g�|�]}t�|��qS�r���r���r-���r���r���r���r0���]���r1���)�graft�prunez#'%s' expects a single <dir_pattern>zunknown action '%s')r���r%���r���r���)r����line�words�action�patternsr����dir_patternr���r���r����_parse_template_lineL���s0�������zFileList._parse_template_linec�����������������C���s@��|���|�\}}}}|dkrV|��dd�|����|D�]}|�j|dd�s2t�d|��q2�n�|dkr�|��dd�|����|D�]}|�j|dd�svt�d |��qv�n�|d kr�|��dd�|����|D�]}|�j|dd�s�t�d |��q��n^|dk�r(|��dd�|����|D�]"}|�j|dd��s�t�d|���q��n|dk�rv|��d|d�|�f���|D�]$}|�j||d��sNt�d||���qNn�|dk�r�|��d|d�|�f���|D�]$}|�j||d��s�t�d||���q�nx|dk�r�|��d|���|�jd�|d��s<t�d|��nB|dk�r0|��d|���|�jd�|d��s<t�d|��ntd|���d�S�)Nr(���zinclude � r"���)�anchorz%warning: no files found matching '%s'r)���zexclude z9warning: no previously-included files found matching '%s'r*���zglobal-include r���z>warning: no files found matching '%s' anywhere in distributionr+���zglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionr2���zrecursive-include %s %s)�prefixz:warning: no files found matching '%s' under directory '%s'r3���zrecursive-exclude %s %szNwarning: no previously-included files matching '%s' found under directory '%s'r5���zgraft z+warning: no directories found matching '%s'r6���zprune z6no previously-included directories found matching '%s'z'this cannot happen: invalid action '%s')r<���r ���r ����include_patternr���r����exclude_patternr���)r���r7���r9���r:���r���r;����patternr���r���r����process_template_lineh���s|����� � � � �� �� � ��zFileList.process_template_liner"���r���c�����������������C���sl���d}t�||||�}|��d|j���|�jdu�r4|�����|�jD�],}|�|�r:|��d|���|�j�|��d}q:|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_patternr ���rB���r ���r����searchr ���r���)r���rB���r>���r?����is_regex�files_found� pattern_re�namer���r���r���r@�������s����� zFileList.include_patternc�����������������C���sr���d}t�||||�}|��d|j���tt|�j�d�dd�D�]4}|�|�j|��r8|��d|�j|����|�j|=�d}q8|S�)a��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 True if files are found, False otherwise. Fz%exclude_pattern: applying regex r'%s'r"���r#���z removing T)rD���r ���rB���r$���r%���r ���rE���)r���rB���r>���r?���rF���rG���rH���r&���r���r���r���rA�������s�����zFileList.exclude_pattern)NN)r"���Nr���)r"���Nr���)�__name__� __module__�__qualname__�__doc__r���r���r����curdirr���r ���r���r���r!���r'���r<���rC���r@���rA���r���r���r���r���r������s��� L ,��r���c�����������������C���s&���dd��t�j|�dd�D��}tt�jj|�S�)z% Find all files under 'path' c�����������������s���s,���|�]$\}}}|D�]}t�j�||�V��qqd�S�r���)r���r���r ���)r.����base�dirsr ����filer���r���r���� <genexpr>����s����z#_find_all_simple.<locals>.<genexpr>T)�followlinks)r����walk�filterr����isfile)r����resultsr���r���r����_find_all_simple����s�����rX���c�����������������C���s6���t�|��}|�tjkr.tjtjj|�d�}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) rX���r���rN���� functools�partialr����relpathr����list)r���r ���Zmake_relr���r���r���r�����s ���� r���c�����������������C���s8���t��|��}tj}tjdkrd}d|�}t�d||�}|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)rB���rH���ra����escapedr���r���r���� glob_to_re��s���� re���r"���c����������� ������C���s ��|rt�|�t�rt�|��S�|�S�td��d�\}}}|�rVt|��}|�|�rP|�|�sZJ��nd}|dur�t|�}|�|�r~|�|�s�J��|t|�t|�t|����}t j } t j dkr�d} |t|�t|�t|����}d||| ||f�}n|�r�d||t|�d��f�}t�|�S�)a��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). �_��Nr^���z\\z%s\A%s%s.*%s%sz%s\A%s)� isinstance�strrb����compilere���� partition� startswith�endswithr%���r���ra���) rB���r>���r?���rF���rY���rf����endrH���Z prefix_rera���r���r���r���rD���%��s*���� rD���)r"���Nr���)rM���r���rb���r_���rZ���Zdistutils.utilr���Zdistutils.errorsr���r���Z distutilsr���r���rX���rN���r���re���rD���r���r���r���r����<module>���s����i