3
ûâdeO  ã               @   s„   d dl mZ d dlmZmZ d dlmZ ddlmZm	Z	m
Z
mZ G dd„ de
ƒZG dd	„ d	e
ƒZG d
d„ de
ƒZG dd„ de
ƒZdS )é    )ÚSpecifierSet)ÚNormalizedNameÚcanonicalize_name)ÚInstallRequirementé   )Ú	CandidateÚCandidateLookupÚRequirementÚformat_namec               @   sˆ   e Zd Zeddœdd„Zedœdd„Zedœdd	„Zee	dœd
d„ƒZ
eedœdd„ƒZedœdd„Zedœdd„Zeedœdd„ZdS )ÚExplicitRequirementN)Ú	candidateÚreturnc             C   s
   || _ d S )N)r   )Úselfr   © r   úO/tmp/pip-build-red6nood/pip/pip/_internal/resolution/resolvelib/requirements.pyÚ__init__
   s    zExplicitRequirement.__init__)r   c             C   s
   t | jƒS )N)Ústrr   )r   r   r   r   Ú__str__   s    zExplicitRequirement.__str__c             C   s   dj | jj| jd�S )Nz{class_name}({candidate!r}))Ú
class_namer   )ÚformatÚ	__class__Ú__name__r   )r   r   r   r   Ú__repr__   s    zExplicitRequirement.__repr__c             C   s   | j jS )N)r   Úproject_name)r   r   r   r   r      s    z ExplicitRequirement.project_namec             C   s   | j jS )N)r   Úname)r   r   r   r   r      s    zExplicitRequirement.namec             C   s
   | j jƒ S )N)r   Úformat_for_error)r   r   r   r   r       s    z$ExplicitRequirement.format_for_errorc             C   s
   | j d fS )N)r   )r   r   r   r   Úget_candidate_lookup#   s    z(ExplicitRequirement.get_candidate_lookupc             C   s
   || j kS )N)r   )r   r   r   r   r   Úis_satisfied_by&   s    z#ExplicitRequirement.is_satisfied_by)r   Ú
__module__Ú__qualname__r   r   r   r   r   Úpropertyr   r   r   r   r   r   Úboolr   r   r   r   r   r   	   s   r   c               @   sˆ   e Zd Zeddœdd„Zedœdd„Zedœdd	„Zee	dœd
d„ƒZ
eedœdd„ƒZedœdd„Zedœdd„Zeedœdd„ZdS )ÚSpecifierRequirementN)Úireqr   c             C   s(   |j d kstdƒ‚|| _t|jƒ| _d S )NzThis is a link, not a specifier)ÚlinkÚAssertionErrorÚ_ireqÚ	frozensetÚextrasÚ_extras)r   r#   r   r   r   r   +   s    zSpecifierRequirement.__init__)r   c             C   s   t | jjƒS )N)r   r&   Úreq)r   r   r   r   r   0   s    zSpecifierRequirement.__str__c             C   s   dj | jjt| jjƒd�S )Nz{class_name}({requirement!r}))r   Úrequirement)r   r   r   r   r&   r*   )r   r   r   r   r   3   s    zSpecifierRequirement.__repr__c             C   s   | j jstdƒ‚t| j jjƒS )Nz'Specifier-backed ireq is always PEP 508)r&   r*   r%   r   r   )r   r   r   r   r   9   s    z!SpecifierRequirement.project_namec             C   s   t | j| jƒS )N)r
   r   r)   )r   r   r   r   r   >   s    zSpecifierRequirement.namec             C   sZ   dd„ t | ƒjdƒD ƒ}t|ƒdkr(dS t|ƒdkr<|d S dj|d d	… ƒd |d
  S )Nc             S   s   g | ]}|j ƒ ‘qS r   )Ústrip)Ú.0Úsr   r   r   ú
<listcomp>H   s    z9SpecifierRequirement.format_for_error.<locals>.<listcomp>ú,r   Ú r   z, z and éÿÿÿÿr2   )r   ÚsplitÚlenÚjoin)r   Úpartsr   r   r   r   B   s    z%SpecifierRequirement.format_for_errorc             C   s
   d | j fS )N)r&   )r   r   r   r   r   P   s    z)SpecifierRequirement.get_candidate_lookup)r   r   c             C   sN   |j | j ks$td|j › d| j › �ƒ‚| jjs4tdƒ‚| jjj}|j|jdd�S )Nz6Internal issue: Candidate is not for this requirement z vs z'Specifier-backed ireq is always PEP 508T)Úprereleases)r   r%   r&   r*   Ú	specifierÚcontainsÚversion)r   r   Úspecr   r   r   r   S   s
    
z$SpecifierRequirement.is_satisfied_by)r   r   r   r   r   r   r   r   r    r   r   r   r   r   r   r   r!   r   r   r   r   r   r"   *   s   r"   c               @   sŽ   e Zd ZdZeeddœdd„Zedœdd„Zedœd	d
„Z	e
edœdd„ƒZe
edœdd„ƒZedœdd„Zedœdd„Zeedœdd„ZdS )ÚRequiresPythonRequirementz4A requirement representing Requires-Python metadata.N)r8   Úmatchr   c             C   s   || _ || _d S )N)r8   Ú
_candidate)r   r8   r=   r   r   r   r   c   s    z"RequiresPythonRequirement.__init__)r   c             C   s   d| j › �S )NzPython )r8   )r   r   r   r   r   g   s    z!RequiresPythonRequirement.__str__c             C   s   dj | jjt| jƒd�S )Nz{class_name}({specifier!r}))r   r8   )r   r   r   r   r8   )r   r   r   r   r   j   s    z"RequiresPythonRequirement.__repr__c             C   s   | j jS )N)r>   r   )r   r   r   r   r   p   s    z&RequiresPythonRequirement.project_namec             C   s   | j jS )N)r>   r   )r   r   r   r   r   t   s    zRequiresPythonRequirement.namec             C   s   t | ƒS )N)r   )r   r   r   r   r   x   s    z*RequiresPythonRequirement.format_for_errorc             C   s"   | j j| jjdd�r| jd fS dS )NT)r7   )NN)r8   r9   r>   r:   )r   r   r   r   r   {   s    
z.RequiresPythonRequirement.get_candidate_lookup)r   r   c             C   s(   |j | jj kstdƒ‚| jj|jdd�S )NzNot Python candidateT)r7   )r   r>   r%   r8   r9   r:   )r   r   r   r   r   r   €   s    z)RequiresPythonRequirement.is_satisfied_by)r   r   r   Ú__doc__r   r   r   r   r   r   r    r   r   r   r   r   r   r!   r   r   r   r   r   r<   `   s   r<   c               @   sŒ   e Zd ZdZeddœdd„Zedœdd„Zedœd	d
„Ze	edœdd„ƒZ
e	edœdd„ƒZedœdd„Zedœdd„Zeedœdd„ZdS )ÚUnsatisfiableRequirementz'A requirement that cannot be satisfied.N)r   r   c             C   s
   || _ d S )N)Ú_name)r   r   r   r   r   r   ‹   s    z!UnsatisfiableRequirement.__init__)r   c             C   s   | j › d�S )Nz (unavailable))rA   )r   r   r   r   r   Ž   s    z UnsatisfiableRequirement.__str__c             C   s   dj | jjt| jƒd�S )Nz{class_name}({name!r}))r   r   )r   r   r   r   rA   )r   r   r   r   r   ‘   s    z!UnsatisfiableRequirement.__repr__c             C   s   | j S )N)rA   )r   r   r   r   r   —   s    z%UnsatisfiableRequirement.project_namec             C   s   | j S )N)rA   )r   r   r   r   r   ›   s    zUnsatisfiableRequirement.namec             C   s   t | ƒS )N)r   )r   r   r   r   r   Ÿ   s    z)UnsatisfiableRequirement.format_for_errorc             C   s   dS )N)NNr   )r   r   r   r   r   ¢   s    z-UnsatisfiableRequirement.get_candidate_lookup)r   r   c             C   s   dS )NFr   )r   r   r   r   r   r   ¥   s    z(UnsatisfiableRequirement.is_satisfied_by)r   r   r   r?   r   r   r   r   r   r    r   r   r   r   r   r   r!   r   r   r   r   r   r@   ˆ   s   r@   N)Z pip._vendor.packaging.specifiersr   Úpip._vendor.packaging.utilsr   r   Zpip._internal.req.req_installr   Úbaser   r   r	   r
   r   r"   r<   r@   r   r   r   r   Ú<module>   s   !6(