a �DOg 2�@s�ddlZddlZddlZddlZddlmZddlmZmZddl m Z Gdd�d�Z dd�Z ej fd d �Zd d �Zddd�ZdS)�N�� convert_path)�DistutilsTemplateError�DistutilsInternalError)�logc@sxeZdZddd�Zdd�Zejfdd�Zdd �Zd d �Z d d �Z dd�Z dd�Z dd�Z dd�Zddd�Zddd�ZdS)�FileListNcCsd|_g|_dS�N)�allfiles�files)�self�warn� debug_print�r�*/usr/lib64/python3.9/distutils/filelist.py�__init__szFileList.__init__cCs ||_dSr)r )r r rrr� set_allfiles#szFileList.set_allfilescCst|�|_dSr)�findallr )r �dirrrrr&szFileList.findallcCsddlm}|rt|�dS)Nr)�DEBUG)Zdistutils.debugr�print)r �msgrrrrr )s zFileList.debug_printcCs|j�|�dSr)r �append)r �itemrrrr3szFileList.appendcCs|j�|�dSr)r �extend)r �itemsrrrr6szFileList.extendcCs<tttjj|j��}g|_|D]}|j�tjj|��qdSr)�sorted�map�os�path�splitr r�join)r Zsortable_filesZ sort_tuplerrr�sort9sz FileList.sortcCs@tt|j�ddd�D]$}|j||j|dkr|j|=qdS)N�r�����)�range�lenr )r �irrr�remove_duplicatesCszFileList.remove_duplicatescCs�|��}|d}d}}}|dvrTt|�dkr ...cSsg|] }t|��qSrr��.0�wrrr� W�z1FileList._parse_template_line..r")�recursive-include�recursive-exclude�z,'%s' expects ...cSsg|] }t|��qSrrr-rrrr0]r1)�graft�prunez#'%s' expects a single zunknown action '%s')rr%rr)r �line�words�action�patternsr� dir_patternrrr�_parse_template_lineLs0  � �  � zFileList._parse_template_linecCs@|�|�\}}}}|dkrV|�dd�|��|D]}|j|dd�s2t�d|�q2�n�|dkr�|�dd�|��|D]}|j|dd�svt�d |�qv�n�|d kr�|�d d�|��|D]}|j|d d�s�t�d |�q��n^|dk�r(|�dd�|��|D]"}|j|d d��st�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��swarning: no files found matching '%s' anywhere in distributionr+zglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionr2zrecursive-include %s %s)�prefixz:warning: no files found matching '%s' under directory '%s'r3zrecursive-exclude %s %szNwarning: no previously-included files matching '%s' found under directory '%s'r5zgraft z+warning: no directories found matching '%s'r6zprune z6no previously-included directories found matching '%s'z'this cannot happen: invalid action '%s')r<r r �include_patternrr �exclude_patternr)r r7r9r:rr;�patternrrr�process_template_linehs|� � �  �   ��   ��  � ��zFileList.process_template_liner"rcCsld}t||||�}|�d|j�|jdur4|��|jD],}|�|�r:|�d|�|j�|�d}q:|S)NFz%include_pattern: applying regex r'%s'z adding T)�translate_patternr rBr r�searchr r)r rBr>r?�is_regex� files_found� pattern_re�namerrrr@�s�    zFileList.include_patterncCsrd}t||||�}|�d|j�tt|j�ddd�D]4}|�|j|�r8|�d|j|�|j|=d}q8|S)NFz%exclude_pattern: applying regex r'%s'r"r#z removing T)rDr rBr$r%r rE)r rBr>r?rFrGrHr&rrrrA�s�zFileList.exclude_pattern)NN)r"Nr)r"Nr)�__name__� __module__� __qualname__rrr�curdirrr rrr!r'r<rCr@rArrrrrs    L ,�rcCs&dd�tj|dd�D�}ttjj|�S)Ncss,|]$\}}}|D]}tj�||�VqqdSr)rrr )r.�base�dirsr �filerrr� �s�z#_find_all_simple..T)� followlinks)r�walk�filterr�isfile)r�resultsrrr�_find_all_simple�s �rWcCs6t|�}|tjkr.tjtjj|d�}t||�}t|�S)N)�start) rWrrM� functools�partialr�relpathr�list)rr Zmake_relrrrrs   rcCs8t�|�}tj}tjdkrd}d|}t�d||�}|S)N�\z\\\\z\1[^%s]z((?t|�}nd}|dur�t|�}|t|�t|�t|��}tj} tjdkr�d} |t|�t|�t|��}d||| ||f}n|r�d||t|�d�f}t�|�S)N�_�r]z\\z%s\A%s%s.*%s%sz%s\A%s) � isinstance�strra�compilerd� partitionr%rr`) rBr>r?rFrXre�endrHZ prefix_rer`rrrrD%s(   rD)r"Nr)rrar^rYZdistutils.utilrZdistutils.errorsrrZ distutilsrrrWrMrrdrDrrrr�s  i