U
��.e�9 � @ s� d Z ddlZddlZddlZddlZddlZddlmZ ddlm Z ddl
mZ dgZe�
e�Ze�dej�Ze�d ejejB �Zejdd
� ZG dd� de�ZdS )zu
Class representing the list of files in a distribution.
Equivalent to distutils.filelist, but fixes some problems.
� N� )�DistlibException)�fsdecode��convert_path�Manifestz\\w*
z#.*?(?=
)|
(?=$)� c @ sz e Zd ZdZddd�Zdd� Zdd� Zd d
� Zddd
�Zdd� Z dd� Z
dd� Zddd�Zd dd�Z
d!dd�Zdd� ZdS )"r z~A list of files built by on exploring the filesystem and filtered by
applying various patterns to what we find there.
Nc C s> t j�t j�|pt �� ��| _| jt j | _d| _t � | _
dS )zd
Initialise an instance.
:param base: The base directory to explore under.
N)�os�path�abspath�normpath�getcwd�base�sep�prefix�allfiles�set�files)�selfr � r �@/usr/lib/python3.8/site-packages/pip/_vendor/distlib/manifest.py�__init__* s zManifest.__init__c C s� ddl m}m}m} g | _}| j}|g}|j}|j}|r�|� }t� |�} | D ]R}
tj
�||
�}t� |�}|j}
||
�r�|�t
|�� qN||
�rN||
�sN||� qNq6dS )zmFind all files under the base and set ``allfiles`` to the absolute
pathnames of files found.
r )�S_ISREG�S_ISDIR�S_ISLNKN)�statr r r r r �pop�appendr �listdirr
�join�st_moder )r r r r r �root�stackr �push�names�name�fullnamer �moder r r �findall9 s"
zManifest.findallc C s4 |� | j�stj�| j|�}| j�tj�|�� dS )zz
Add a file to the manifest.
:param item: The pathname to add. This can be relative to the base.
N) �
startswithr r r
r r r �addr )r �itemr r r r* T s zManifest.addc C s |D ]}| � |� qdS )z�
Add a list of files to the manifest.
:param items: The pathnames to add. These can be relative to the base.
N)r* )r �itemsr+ r r r �add_many^ s zManifest.add_manyFc sb � �fdd�� t �j�}|rFt � }|D ]}� |tj�|�� q&||O }dd� tdd� |D ��D �S )z8
Return sorted files in directory order
c sJ | � |� t�d|� |�jkrFtj�|�\}}|dks