
(hQ                 @   s   d  d l  m Z d  d l m Z d d l m Z m Z e rr d  d l m Z d  d l	 m
 Z
 d d l m Z m Z Gd d	   d	 e  Z Gd
 d   d e  Z Gd d   d e  Z Gd d   d e  Z d S)    )canonicalize_name)MYPY_CHECK_RUNNING   )Requirementformat_name)SpecifierSet)InstallRequirement)	CandidateCandidateLookupc               @   s|   e  Z d  Z d d   Z d d   Z d d   Z e d d    Z e d	 d
    Z d d   Z	 d d   Z
 d d   Z d S)ExplicitRequirementc             C   s   | |  _  d  S)N)	candidate)selfr    r   O/tmp/pip-build-kmztzv_d/pip/pip/_internal/resolution/resolvelib/requirements.py__init__   s    zExplicitRequirement.__init__c             C   s   t  |  j  S)N)strr   )r   r   r   r   __str__   s    zExplicitRequirement.__str__c             C   s   d j  d |  j j d |  j  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_by3   s    z#ExplicitRequirement.is_satisfied_byN)r   
__module____qualname__r   r   r   propertyr   r   r   r   r   r   r   r   r   r      s   r   c               @   s|   e  Z d  Z d d   Z d d   Z d d   Z e d d    Z e d	 d
    Z d d   Z	 d d   Z
 d d   Z d S)SpecifierRequirementc             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   Zireqr   r   r   r   9   s    	zSpecifierRequirement.__init__c             C   s   t  |  j j  S)N)r   r#   req)r   r   r   r   r   ?   s    zSpecifierRequirement.__str__c             C   s(   d j  d |  j j d t |  j j   S)Nz{class_name}({requirement!r})r   requirement)r   r   r   r   r#   r'   )r   r   r   r   r   C   s    	zSpecifierRequirement.__repr__c             C   s   t  |  j j j  S)N)r   r#   r'   r   )r   r   r   r   r   J   s    z!SpecifierRequirement.project_namec             C   s   t  |  j |  j  S)N)r   r   r&   )r   r   r   r   r   O   s    zSpecifierRequirement.namec             C   su   d d   t  |   j d  D } t |  d k r8 d St |  d k rR | d Sd j | d  d	   d | d
 S)Nc             S   s   g  |  ] } | j     q Sr   )strip).0sr   r   r   
<listcomp>[   s   	 z9SpecifierRequirement.format_for_error.<locals>.<listcomp>,r    r   z, z and r/   )r   splitlenjoin)r   partsr   r   r   r   T   s    "z%SpecifierRequirement.format_for_errorc             C   s   d  |  j  f S)N)r#   )r   r   r   r   r   c   s    z)SpecifierRequirement.get_candidate_lookupc             C   sU   | j  |  j  k s0 t d j | j  |  j     |  j j j } | j | j d d S)Nz?Internal issue: Candidate is not for this requirement  {} vs {}prereleasesT)r   r"   r   r#   r'   	specifiercontainsversion)r   r   specr   r   r   r   g   s
    z$SpecifierRequirement.is_satisfied_byN)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    8   s   r    c               @   s   e  Z d  Z d Z d d   Z d d   Z d d   Z e d d	    Z e d
 d    Z	 d d   Z
 d d   Z d d   Z d S)RequiresPythonRequirementz9A requirement representing Requires-Python metadata.
    c             C   s   | |  _  | |  _ d  S)N)r5   
_candidate)r   r5   matchr   r   r   r   v   s    	z"RequiresPythonRequirement.__init__c             C   s   d j  |  j  S)Nz	Python {})r   r5   )r   r   r   r   r   {   s    z!RequiresPythonRequirement.__str__c             C   s%   d j  d |  j j d t |  j   S)Nz{class_name}({specifier!r})r   r5   )r   r   r   r   r5   )r   r   r   r   r      s    	z"RequiresPythonRequirement.__repr__c             C   s
   |  j  j S)N)r:   r   )r   r   r   r   r      s    z&RequiresPythonRequirement.project_namec             C   s
   |  j  j S)N)r:   r   )r   r   r   r   r      s    zRequiresPythonRequirement.namec             C   s
   t  |   S)N)r   )r   r   r   r   r      s    z*RequiresPythonRequirement.format_for_errorc             C   s/   |  j  j |  j j d d r+ |  j d  f Sd S)Nr4   T)NN)r5   r6   r:   r7   )r   r   r   r   r      s    z.RequiresPythonRequirement.get_candidate_lookupc             C   s:   | j  |  j j  k s! t d   |  j j | j d d S)NzNot Python candidater4   T)r   r:   r"   r5   r6   r7   )r   r   r   r   r   r      s    !z)RequiresPythonRequirement.is_satisfied_byN)r   r   r   __doc__r   r   r   r   r   r   r   r   r   r   r   r   r   r9   s   s   r9   c               @   s   e  Z d  Z d Z d d   Z d d   Z d d   Z e d d	    Z e d
 d    Z	 d d   Z
 d d   Z d d   Z d S)UnsatisfiableRequirementz,A requirement that cannot be satisfied.
    c             C   s   | |  _  d  S)N)_name)r   r   r   r   r   r      s    z!UnsatisfiableRequirement.__init__c             C   s   d j  |  j  S)Nz{} (unavailable))r   r>   )r   r   r   r   r      s    z UnsatisfiableRequirement.__str__c             C   s%   d j  d |  j j d t |  j   S)Nz{class_name}({name!r})r   r   )r   r   r   r   r>   )r   r   r   r   r      s    	z!UnsatisfiableRequirement.__repr__c             C   s   |  j  S)N)r>   )r   r   r   r   r      s    z%UnsatisfiableRequirement.project_namec             C   s   |  j  S)N)r>   )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_lookupc             C   s   d S)NFr   )r   r   r   r   r   r      s    z(UnsatisfiableRequirement.is_satisfied_byN)r   r   r   r<   r   r   r   r   r   r   r   r   r   r   r   r   r   r=      s   r=   N)pip._vendor.packaging.utilsr   Zpip._internal.utils.typingr   baser   r   Z pip._vendor.packaging.specifiersr   Zpip._internal.req.req_installr   r	   r
   r   r    r9   r=   r   r   r   r   <module>   s   );0