
0c@_Ÿ  ã               @   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 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 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-jynh7p1z/pip/pip/_internal/resolution/resolvelib/requirements.pyÚ__init__   s    zExplicitRequirement.__init__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   Ú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_byN)
r   Ú
__module__Ú__qualname__r   r   Úpropertyr   r   r   r   r   r   r   r   r      s   r   c               @   sj   e  Z d  Z d d „  Z d d „  Z 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   /   s    	zSpecifierRequirement.__init__c             C   s   t  |  j j ƒ S)N)Ústrr    Úreq)r   r   r   r   Ú__str__5   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   9   s    	zSpecifierRequirement.__repr__c             C   s%   t  |  j j j ƒ } t | |  j ƒ S)N)r   r    r%   r   r   r#   )r   Úcanonical_namer   r   r   r   @   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>M   s   	 z9SpecifierRequirement.format_for_error.<locals>.<listcomp>ú,r   Ú r   z, z and éÿÿÿÿr/   )r$   ÚsplitÚlenÚjoin)r   Úpartsr   r   r   r   F   s    "z%SpecifierRequirement.format_for_errorc             C   s   d  |  j  f S)N)r    )r   r   r   r   r   U   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   Y   s
    z$SpecifierRequirement.is_satisfied_byN)r   r   r   r   r&   r   r   r   r   r   r   r   r   r   r   r   .   s   r   c               @   sd   e  Z d  Z d Z d d „  Z 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   h   s    	z"RequiresPythonRequirement.__init__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   m   s    	z"RequiresPythonRequirement.__repr__c             C   s
   |  j  j S)N)r:   r   )r   r   r   r   r   t   s    zRequiresPythonRequirement.namec             C   s   d t  |  j ƒ S)NzPython )r$   r5   )r   r   r   r   r   y   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   r9   e   s   r9   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   Ú<module>   s   7