AlkantarClanX12

Your IP : 3.137.169.14


Current Path : /opt/alt/python37/lib/python3.7/site-packages/distlib/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/distlib/__pycache__/manifest.cpython-37.pyc

B

:��a�9�@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZdgZe�
e�Ze�dej�Ze�d	ejejB�Zejdd
�ZGdd�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@szeZdZdZddd�Zdd�Zdd�Zd	d
�Zddd
�Zdd�Z	dd�Z
dd�Zddd�Zd dd�Z
d!dd�Zdd�ZdS)"rz~A list of files built by on exploring the filesystem and filtered by
    applying various patterns to what we find there.
    NcCs>tj�tj�|pt����|_|jtj|_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�A/opt/alt/python37/lib/python3.7/site-packages/distlib/manifest.py�__init__*szManifest.__init__cCs�ddlm}m}m}g|_}|j}|g}|j}|j}xt|r�|�}t�	|�}	xZ|	D]R}
tj
�||
�}t�|�}|j}
||
�r�|�t
|��qR||
�rR||
�sR||�qRWq8WdS)zmFind all files under the base and set ``allfiles`` to the absolute
        pathnames of files found.
        r)�S_ISREG�S_ISDIR�S_ISLNKN)�statrrrrr
�pop�appendr�listdirr	�join�st_moder)rrrrr�root�stackr�push�names�name�fullnamer�moderrr�findall9s"



zManifest.findallcCs4|�|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)	�
startswithrrr	rr
r�addr)r�itemrrrr)TszManifest.addcCsx|D]}|�|�qWdS)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*rrr�add_many^s
zManifest.add_manyFcsf��fdd��t�j�}|rJt�}x|D]}�|tj�|��q(W||O}dd�tdd�|D��D�S)z8
        Return sorted files in directory order
        csJ|�|�t�d|�|�jkrFtj�|�\}}|dks<t��||�dS)Nzadd_dir added %s)��/)r)�logger�debugr
rr	�split�AssertionError)�dirs�d�parent�_)�add_dirrrrr7ls

z Manifest.sorted.<locals>.add_dircSsg|]}tjj|��qSr)rr	r)�.0Z
path_tuplerrr�
<listcomp>zsz#Manifest.sorted.<locals>.<listcomp>css|]}tj�|�VqdS)N)rr	r1)r8r	rrr�	<genexpr>{sz"Manifest.sorted.<locals>.<genexpr>)rrrr	�dirname�sorted)rZwantdirs�resultr3�fr)r7rrr<gs

zManifest.sortedcCst�|_g|_dS)zClear all collected files.N)rrr)rrrr�clear}szManifest.clearcCs�|�|�\}}}}|dkrFx&|D]}|j|dd�s t�d|�q W�n:|dkrnx|D]}|j|dd�}qTW�n|dkr�x&|D]}|j|dd�s|t�d|�q|Wn�|d	kr�x�|D]}|j|dd�}q�Wn�|d
kr�x�|D] }|j||d�s�t�d||�q�Wn�|d
k�r$xz|D]}|j||d�}�q
Wn\|dk�rL|jd|d��s�t�d|�n4|dk�rt|jd|d��s�t�d|�ntd|��dS)av
        Process a directive which either adds some files from ``allfiles`` to
        ``files``, or removes some files from ``files``.

        :param directive: The directive to process. This should be in a format
                     compatible with distutils ``MANIFEST.in`` files:

                     http://docs.python.org/distutils/sourcedist.html#commands
        �includeT)�anchorzno files found matching %r�excludezglobal-includeFz3no files found matching %r anywhere in distributionzglobal-excludezrecursive-include)rz-no files found matching %r under directory %rzrecursive-exclude�graftNz no directories found matching %r�prunez4no previously-included directories found matching %rzinvalid action %r)�_parse_directive�_include_patternr/�warning�_exclude_patternr)r�	directive�action�patterns�thedirZ
dirpattern�pattern�foundrrr�process_directive�sD








zManifest.process_directivecCs|��}t|�dkr,|ddkr,|�dd�|d}d}}}|dkrxt|�dkr`td|��d	d
�|dd�D�}n~|dkr�t|�dkr�td
|��t|d�}dd
�|dd�D�}n:|dkr�t|�dkr�td|��t|d�}ntd|��||||fS)z�
        Validate a directive.
        :param directive: The directive to validate.
        :return: A tuple of action, patterns, thedir, dir_patterns
        rr)r@rBzglobal-includezglobal-excludezrecursive-includezrecursive-excluderCrDr@N)r@rBzglobal-includezglobal-excluderz$%r expects <pattern1> <pattern2> ...cSsg|]}t|��qSr)r)r8�wordrrrr9�sz-Manifest._parse_directive.<locals>.<listcomp>)zrecursive-includezrecursive-exclude�z*%r expects <dir> <pattern1> <pattern2> ...cSsg|]}t|��qSr)r)r8rPrrrr9�s)rCrDz!%r expects a single <dir_pattern>zunknown action %r)r1�len�insertrr)rrI�wordsrJrKrLZdir_patternrrrrE�s.


zManifest._parse_directiveTcCsTd}|�||||�}|jdkr&|��x(|jD]}|�|�r.|j�|�d}q.W|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.
        FNT)�_translate_patternrr'�searchrr))rrMrAr�is_regexrN�
pattern_rer$rrrrFs

zManifest._include_patterncCsFd}|�||||�}x,t|j�D]}|�|�r |j�|�d}q W|S)atRemove 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.

        This API is public to allow e.g. exclusion of SCM subdirs, e.g. when
        packaging source distributions
        FT)rU�listrrV�remove)rrMrArrWrNrXr>rrrrH)s
zManifest._exclude_patternc
Cs�|rt|t�rt�|�S|Stdkr:|�d��d�\}}}|rj|�|�}tdkrn|�|�rd|�|�snt	�nd}t�
tj�
|jd��}	|dk	�rftdkr�|�d�}
|�|�dt|
��}n>|�|�}|�|�r�|�|�s�t	�|t|�t|�t|��}tj}tjdk�rd}tdk�r4d|	|�
|d|f�}n0|t|�t|�t|��}d	||	||||f}n8|�r�tdk�r�d|	|}nd
||	|t|�d�f}t�|�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).
        )rQrr6r-N�\z\\�^z.*z%s%s%s%s.*%s%sz%s%s%s)�
isinstance�str�re�compile�_PYTHON_VERSION�_glob_to_re�	partitionr(�endswithr2�escaperr	rr
rRr)
rrMrArrW�startr6�endrXr
Z
empty_patternZ	prefix_rerrrrrU=sB	








zManifest._translate_patterncCs8t�|�}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).
        r[z\\\\z\1[^%s]z((?<!\\)(\\\\)*)\.)�fnmatch�	translaterrr_�sub)rrMrXr�escapedrrrrbts

zManifest._glob_to_re)N)F)TNF)TNF)TNF)�__name__�
__module__�__qualname__�__doc__rr'r)r,r<r?rOrErFrHrUrbrrrrr%s 

	
O/
(

6)rorh�loggingrr_�sysr-r�compatr�utilr�__all__�	getLoggerrlr/r`�MZ_COLLAPSE_PATTERN�SZ_COMMENTED_LINE�version_infora�objectrrrrr�<module>
s