3
g_+                 @   sR  d dl Zd dlZd dlZd dlZd dlZd dlmZmZm	Z	m
Z
mZmZmZmZmZ d dlmZ d dlmZmZ d dlmZ d dlmZmZ d dlmZmZmZ d dlmZ d d	l m!Z! d d
l"m#Z# erd dlm$Z$ ne%Z$eeef Z&ej'e(Z)G dd de$Z*G dd de$Z+G dd dZ,G dd de$Z-G dd de-Z.G dd de-Z/dS )    N)	IOTYPE_CHECKING
Collection	ContainerIterableIteratorListOptionalUnion)Requirement)InvalidSpecifierSpecifierSet)NormalizedName)LegacyVersionVersion)DIRECT_URL_METADATA_NAME	DirectUrlDirectUrlValidationError)stdlib_pkgs)egg_link_path_from_sys_path)url_to_path)Protocolc               @   sB   e Zd ZeedddZeedddZeedddZdS )	BaseEntryPoint)returnc             C   s
   t  d S )N)NotImplementedError)self r   Y/var/www/tester-filtro-web/env/lib/python3.6/site-packages/pip/_internal/metadata/base.pyname+   s    zBaseEntryPoint.namec             C   s
   t  d S )N)r   )r   r   r   r   value/   s    zBaseEntryPoint.valuec             C   s
   t  d S )N)r   )r   r   r   r   group3   s    zBaseEntryPoint.groupN)__name__
__module____qualname__propertystrr   r   r    r   r   r   r   r   *   s   r   c               @   s  e Zd ZedddZedddZeee dddZeee ddd	Z	eee dd
dZ
eedddZeedddZeee dddZeedddZeedddZeedddZeedddZeedddZeedddZee ddd Zeejjdd!d"Zeee dd#d$Zeedd%d&Z ee!dd'd(Z"f fe#e ee$ d)d*d+Z%ee dd,d-Z&d.S )/BaseDistribution)r   c             C   s   | j  d| j d| j dS )N z ())raw_nameversionlocation)r   r   r   r   __repr__9   s    zBaseDistribution.__repr__c             C   s   | j  d| j S )Nr'   )r)   r*   )r   r   r   r   __str__<   s    zBaseDistribution.__str__c             C   s
   t  dS )a  Where the distribution is loaded from.

        A string value is not necessarily a filesystem path, since distributions
        can be loaded from other sources, e.g. arbitrary zip archives. ``None``
        means the distribution is created in-memory.

        Do not canonicalize this value with e.g. ``pathlib.Path.resolve()``. If
        this is a symbolic link, we want to preserve the relative path between
        it and files in the distribution.
        N)r   )r   r   r   r   r+   ?   s    zBaseDistribution.locationc             C   s6   | j }|r|j r2t|jS nt| j}|r2| jS dS )zThe project location for editable distributions.

        This is the directory where pyproject.toml or setup.py is located.
        None if the distribution is not installed in editable mode.
        N)
direct_urlZis_local_editabler   urlr   r)   r+   )r   r.   Zegg_link_pathr   r   r   editable_project_locationM   s    
z*BaseDistribution.editable_project_locationc             C   s
   t  dS )a'  Location of the .[egg|dist]-info directory.

        Similarly to ``location``, a string value is not necessarily a
        filesystem path. ``None`` means the distribution is created in-memory.

        For a modern .dist-info installation on disk, this should be something
        like ``{location}/{raw_name}-{version}.dist-info``.

        Do not canonicalize this value with e.g. ``pathlib.Path.resolve()``. If
        this is a symbolic link, we want to preserve the relative path between
        it and other files in the distribution.
        N)r   )r   r   r   r   info_directoryc   s    zBaseDistribution.info_directoryc             C   s
   t  d S )N)r   )r   r   r   r   canonical_names   s    zBaseDistribution.canonical_namec             C   s
   t  d S )N)r   )r   r   r   r   r*   w   s    zBaseDistribution.versionc             C   sn   y| j t}W n tk
r"   dS X y
tj|S  ttjtfk
rh } zt	j
dt| j| dS d}~X nX dS )zObtain a DirectUrl from this distribution.

        Returns None if the distribution has no `direct_url.json` metadata,
        or if `direct_url.json` is invalid.
        NzError parsing %s for %s: %s)	read_textr   FileNotFoundErrorr   Z	from_jsonUnicodeDecodeErrorjsonJSONDecodeErrorr   loggerwarningr2   )r   contenter   r   r   r.   {   s     
zBaseDistribution.direct_urlc             C   s
   t  d S )N)r   )r   r   r   r   	installer   s    zBaseDistribution.installerc             C   s
   t | jS )N)boolr0   )r   r   r   r   editable   s    zBaseDistribution.editablec             C   s
   t  d S )N)r   )r   r   r   r   local   s    zBaseDistribution.localc             C   s
   t  d S )N)r   )r   r   r   r   in_usersite   s    zBaseDistribution.in_usersitec             C   s
   t  d S )N)r   )r   r   r   r   in_site_packages   s    z!BaseDistribution.in_site_packages)r   r   c             C   s
   t  dS )zRead a file in the .dist-info (or .egg-info) directory.

        Should raise ``FileNotFoundError`` if ``name`` does not exist in the
        metadata directory.
        N)r   )r   r   r   r   r   r3      s    zBaseDistribution.read_textc             C   s
   t  d S )N)r   )r   r   r   r   iter_entry_points   s    z"BaseDistribution.iter_entry_pointsc             C   s
   t  dS )z?Metadata of distribution parsed from e.g. METADATA or PKG-INFO.N)r   )r   r   r   r   metadata   s    zBaseDistribution.metadatac             C   s   | j jdS )zDValue of "Metadata-Version:" in distribution metadata, if available.zMetadata-Version)rC   get)r   r   r   r   metadata_version   s    z!BaseDistribution.metadata_versionc             C   s   | j jd| jS )z*Value of "Name:" in distribution metadata.Name)rC   rD   r2   )r   r   r   r   r)      s    zBaseDistribution.raw_namec             C   sf   | j jd}|dkrt S ytt|}W n6 tk
r` } zd}tj|| j| t S d}~X nX |S )zValue of "Requires-Python:" in distribution metadata.

        If the key does not exist or contains an invalid value, an empty
        SpecifierSet should be returned.
        zRequires-PythonNz-Package %r has an invalid Requires-Python: %s)rC   rD   r   r%   r   r8   r9   r)   )r   r   specr;   messager   r   r   requires_python   s    z BaseDistribution.requires_python)extrasr   c             C   s
   t  dS )zDependencies of this distribution.

        For modern .dist-info distributions, this is the collection of
        "Requires-Dist:" entries in distribution metadata.
        N)r   )r   rJ   r   r   r   iter_dependencies   s    z"BaseDistribution.iter_dependenciesc             C   s
   t  dS )zExtras provided by this distribution.

        For modern .dist-info distributions, this is the collection of
        "Provides-Extra:" entries in distribution metadata.
        N)r   )r   r   r   r   iter_provided_extras   s    z%BaseDistribution.iter_provided_extrasN)'r!   r"   r#   r%   r,   r-   r$   r	   r+   r0   r1   r   r2   DistributionVersionr*   r   r.   r<   r=   r>   r?   r@   rA   r3   r   r   rB   emailrH   MessagerC   rE   r)   r   rI   r   r   rK   rL   r   r   r   r   r&   8   sH   r&   c               @   s   e Zd ZdZed dddZeeee  d dddZ	eed d	d
dZ
ed dddZed dddZdedddfeee eeeee dddZdS )BaseEnvironmentz6An environment containing distributions to introspect.)r   c             C   s
   t  d S )N)r   )clsr   r   r   default   s    zBaseEnvironment.default)pathsr   c             C   s
   t  d S )N)r   )rQ   rS   r   r   r   
from_paths   s    zBaseEnvironment.from_pathsr&   )r   r   c             C   s
   t  dS )z=Given a requirement name, return the installed distributions.N)r   )r   r   r   r   r   get_distribution   s    z BaseEnvironment.get_distributionc             C   s
   t  dS )a  Iterate through installed distributions.

        This function should be implemented by subclass, but never called
        directly. Use the public ``iter_distribution()`` instead, which
        implements additional logic to make sure the distributions are valid.
        N)r   )r   r   r   r   _iter_distributions   s    z#BaseEnvironment._iter_distributionsc             c   sH   xB| j  D ]6}tjd|jtjd}|s:tjd|j|j q
|V  q
W dS )z(Iterate through installed distributions.z)^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$)flagsz%Ignoring invalid distribution %s (%s)N)rV   rematchr2   
IGNORECASEr8   r9   r+   )r   distZproject_name_validr   r   r   iter_distributions  s    
z"BaseEnvironment.iter_distributionsTF)
local_onlyskipinclude_editableseditables_only	user_onlyr   c                sb   | j  }|rdd |D }|s,dd |D }|r>dd |D }|rPdd |D } fdd|D S )a  Return a list of installed distributions.

        :param local_only: If True (default), only return installations
        local to the current virtualenv, if in a virtualenv.
        :param skip: An iterable of canonicalized project names to ignore;
            defaults to ``stdlib_pkgs``.
        :param include_editables: If False, don't report editables.
        :param editables_only: If True, only report editables.
        :param user_only: If True, only report installations in the user
        site directory.
        c             s   s   | ]}|j r|V  qd S )N)r?   ).0dr   r   r   	<genexpr>+  s    z?BaseEnvironment.iter_installed_distributions.<locals>.<genexpr>c             s   s   | ]}|j s|V  qd S )N)r>   )rb   rc   r   r   r   rd   -  s    c             s   s   | ]}|j r|V  qd S )N)r>   )rb   rc   r   r   r   rd   /  s    c             s   s   | ]}|j r|V  qd S )N)r@   )rb   rc   r   r   r   rd   1  s    c             3   s   | ]}|j  kr|V  qd S )N)r2   )rb   rc   )r^   r   r   rd   2  s    )r\   )r   r]   r^   r_   r`   ra   itr   )r^   r   iter_installed_distributions  s    z,BaseEnvironment.iter_installed_distributionsN)r!   r"   r#   __doc__classmethodrR   r	   r   r%   rT   rU   r   rV   r\   r   r=   r   r&   rf   r   r   r   r   rP      s   	rP   c               @   s"   e Zd ZU eejdddZdS )Wheel)r   c             C   s
   t  d S )N)r   )r   r   r   r   
as_zipfile8  s    zWheel.as_zipfileN)r!   r"   r#   r%   r+   zipfileZipFilerj   r   r   r   r   ri   5  s   
ri   c               @   s,   e Zd ZeddddZejdddZdS )FilesystemWheelN)r+   r   c             C   s
   || _ d S )N)r+   )r   r+   r   r   r   __init__=  s    zFilesystemWheel.__init__)r   c             C   s   t j| jddS )NT)
allowZip64)rk   rl   r+   )r   r   r   r   rj   @  s    zFilesystemWheel.as_zipfile)r!   r"   r#   r%   rn   rk   rl   rj   r   r   r   r   rm   <  s   rm   c               @   s2   e Zd Zeee ddddZejdddZ	dS )MemoryWheelN)r+   streamr   c             C   s   || _ || _d S )N)r+   rq   )r   r+   rq   r   r   r   rn   E  s    zMemoryWheel.__init__)r   c             C   s   t j| jddS )NT)ro   )rk   rl   rq   )r   r   r   r   rj   I  s    zMemoryWheel.as_zipfile)
r!   r"   r#   r%   r   bytesrn   rk   rl   rj   r   r   r   r   rp   D  s   rp   )0email.messagerN   r6   loggingrX   rk   typingr   r   r   r   r   r   r   r	   r
   Z"pip._vendor.packaging.requirementsr   Z pip._vendor.packaging.specifiersr   r   pip._vendor.packaging.utilsr   Zpip._vendor.packaging.versionr   r   Zpip._internal.models.direct_urlr   r   r   pip._internal.utils.compatr   pip._internal.utils.egg_linkr   Zpip._internal.utils.urlsr   r   objectrM   	getLoggerr!   r8   r   r&   rP   ri   rm   rp   r   r   r   r   <module>   s2   ,
 2L