
@Wym                 @   sE  d  d l  m Z m Z m Z d  d l Z d  d l Z d  d l Z d  d l Z d d l m	 Z	 m
 Z
 d d l m Z m Z m Z Gd d   d e  Z Gd d	   d	 e
 e j e   Z Gd
 d   d e  Z Gd d   d e  Z d d   Z Gd d   d e  Z e j d  Z d d   Z d d   Z Gd d   d e  Z d S)    )absolute_importdivisionprint_functionN   )string_typeswith_metaclass)VersionLegacyVersionparsec               @   s   e  Z d  Z d Z d S)InvalidSpecifierzH
    An invalid specifier was found, users should refer to PEP 440.
    N)__name__
__module____qualname____doc__ r   r   ?/tmp/pip-build-sgmvqjpy/pip/pip/_vendor/packaging/specifiers.pyr      s   r   c               @   s   e  Z d  Z e j d d    Z e j d d    Z e j d d    Z e j d d    Z e j	 d	 d
    Z
 e
 j d d
    Z
 e j d d d   Z e j d d d   Z d S)BaseSpecifierc             C   s   d S)z
        Returns the str representation of this Specifier like object. This
        should be representative of the Specifier itself.
        Nr   )selfr   r   r   __str__   s    zBaseSpecifier.__str__c             C   s   d S)zF
        Returns a hash value for this Specifier like object.
        Nr   )r   r   r   r   __hash__   s    zBaseSpecifier.__hash__c             C   s   d S)zq
        Returns a boolean representing whether or not the two Specifier like
        objects are equal.
        Nr   )r   otherr   r   r   __eq__$   s    zBaseSpecifier.__eq__c             C   s   d S)zu
        Returns a boolean representing whether or not the two Specifier like
        objects are not equal.
        Nr   )r   r   r   r   r   __ne__+   s    zBaseSpecifier.__ne__c             C   s   d S)zg
        Returns whether or not pre-releases as a whole are allowed by this
        specifier.
        Nr   )r   r   r   r   prereleases2   s    zBaseSpecifier.prereleasesc             C   s   d S)zd
        Sets whether or not pre-releases as a whole are allowed by this
        specifier.
        Nr   )r   valuer   r   r   r   9   s    Nc             C   s   d S)zR
        Determines if the given item is contained within this specifier.
        Nr   )r   itemr   r   r   r   contains@   s    zBaseSpecifier.containsc             C   s   d S)z
        Takes an iterable of items and filters them so that only items which
        are contained within this specifier are allowed in it.
        Nr   )r   iterabler   r   r   r   filterF   s    zBaseSpecifier.filter)r   r   r   abcabstractmethodr   r   r   r   abstractpropertyr   setterr   r   r   r   r   r   r      s   r   c               @   s   e  Z d  Z i  Z d d d d  Z d d   Z d d   Z d	 d
   Z d d   Z d d   Z	 d d   Z
 d d   Z e d d    Z e d d    Z e d d    Z e j d d    Z d d   Z d d d  Z d d d  Z d S) _IndividualSpecifier Nc             C   sj   |  j  j |  } | s0 t d j |    n  | j d  j   | j d  j   f |  _ | |  _ d  S)NzInvalid specifier: '{0}'operatorversion)_regexsearchr   formatgroupstrip_spec_prereleases)r   specr   matchr   r   r   __init__R   s    z_IndividualSpecifier.__init__c             C   sF   |  j  d  k	 r! d j |  j  n d } d j |  j j t |   |  S)Nz, prereleases={0!r}r$   z<{0}({1!r}{2})>)r-   r)   r   	__class__r   str)r   prer   r   r   __repr___   s    !		z_IndividualSpecifier.__repr__c             C   s   d j  |  j   S)Nz{0}{1})r)   r,   )r   r   r   r   r   l   s    z_IndividualSpecifier.__str__c             C   s   t  |  j  S)N)hashr,   )r   r   r   r   r   o   s    z_IndividualSpecifier.__hash__c             C   sd   t  | t  r> y |  j |  } WqT t k
 r: t SYqT Xn t  | |  j  sT t S|  j | j k S)N)
isinstancer   r1   r   NotImplementedr,   )r   r   r   r   r   r   r   s    z_IndividualSpecifier.__eq__c             C   sd   t  | t  r> y |  j |  } WqT t k
 r: t SYqT Xn t  | |  j  sT t S|  j | j k S)N)r6   r   r1   r   r7   r,   )r   r   r   r   r   r   }   s    z_IndividualSpecifier.__ne__c             C   s   t  |  d j |  j |   S)Nz_compare_{0})getattrr)   
_operators)r   opr   r   r   _get_operator   s    z"_IndividualSpecifier._get_operatorc             C   s(   t  | t t f  s$ t |  } n  | S)N)r6   r	   r   r
   )r   r&   r   r   r   _coerce_version   s    z$_IndividualSpecifier._coerce_versionc             C   s   |  j  d S)Nr   )r,   )r   r   r   r   r%      s    z_IndividualSpecifier.operatorc             C   s   |  j  d S)Nr   )r,   )r   r   r   r   r&      s    z_IndividualSpecifier.versionc             C   s   |  j  S)N)r-   )r   r   r   r   r      s    z _IndividualSpecifier.prereleasesc             C   s   | |  _  d  S)N)r-   )r   r   r   r   r   r      s    c             C   s   |  j  |  S)N)r   )r   r   r   r   r   __contains__   s    z!_IndividualSpecifier.__contains__c             C   sW   | d  k r |  j  } n  |  j |  } | j r; | r; d S|  j |  j  | |  j  S)NF)r   r<   is_prereleaser;   r%   r&   )r   r   r   r   r   r   r      s    z_IndividualSpecifier.containsc             c   s   d } g  } i | d  k	 r! | n d d 6} xf | D]^ } |  j  |  } |  j | |  r2 | j r | pn |  j r | j |  q d } | Vq2 q2 W| r | r x | D] } | Vq Wn  d  S)NFTr   )r<   r   r>   r   append)r   r   r   yieldedfound_prereleaseskwr&   parsed_versionr   r   r   r      s    	z_IndividualSpecifier.filter)r   r   r   r9   r0   r4   r   r   r   r   r;   r<   propertyr%   r&   r   r"   r=   r   r   r   r   r   r   r#   N   s    r#   c               @   s   e  Z d  Z d Z e j d e d e j e j B Z i d d 6d d 6d d	 6d
 d 6d d 6d d 6Z	 d d   Z
 d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d S)LegacySpecifiera  
        (?P<operator>(==|!=|<=|>=|<|>))
        \s*
        (?P<version>
            [^,;\s)]* # Since this is a "legacy" specifier, and the version
                      # string can be just about anything, we match everything
                      # except for whitespace, a semi-colon for marker support,
                      # a closing paren since versions can be enclosed in
                      # them, and a comma since it's a version separator.
        )
        z^\s*z\s*$equalz==	not_equalz!=less_than_equalz<=greater_than_equalz>=	less_than<greater_than>c             C   s(   t  | t  s$ t t |   } n  | S)N)r6   r	   r2   )r   r&   r   r   r   r<      s    zLegacySpecifier._coerce_versionc             C   s   | |  j  |  k S)N)r<   )r   prospectiver.   r   r   r   _compare_equal   s    zLegacySpecifier._compare_equalc             C   s   | |  j  |  k S)N)r<   )r   rN   r.   r   r   r   _compare_not_equal   s    z"LegacySpecifier._compare_not_equalc             C   s   | |  j  |  k S)N)r<   )r   rN   r.   r   r   r   _compare_less_than_equal   s    z(LegacySpecifier._compare_less_than_equalc             C   s   | |  j  |  k S)N)r<   )r   rN   r.   r   r   r   _compare_greater_than_equal   s    z+LegacySpecifier._compare_greater_than_equalc             C   s   | |  j  |  k  S)N)r<   )r   rN   r.   r   r   r   _compare_less_than  s    z"LegacySpecifier._compare_less_thanc             C   s   | |  j  |  k S)N)r<   )r   rN   r.   r   r   r   _compare_greater_than  s    z%LegacySpecifier._compare_greater_thanN)r   r   r   
_regex_strrecompileVERBOSE
IGNORECASEr'   r9   r<   rO   rP   rQ   rR   rS   rT   r   r   r   r   rE      s"   
rE   c                s%   t  j      f d d    } | S)Nc                s#   t  | t  s d S  |  | |  S)NF)r6   r   )r   rN   r.   )fnr   r   wrapped  s    z)_require_version_compare.<locals>.wrapped)	functoolswraps)rZ   r[   r   )rZ   r   _require_version_compare
  s    !r^   c               @   s)  e  Z d  Z d Z e j d e d e j e j B Z i d d 6d d 6d d	 6d
 d 6d d 6d d 6d d 6d d 6Z	 e
 d d    Z e
 d d    Z e
 d d    Z e
 d d    Z e
 d d    Z e
 d d    Z e
 d  d!    Z d" d#   Z e d$ d%    Z e j d& d%    Z d' S)(	Specifiera  
        (?P<operator>(~=|==|!=|<=|>=|<|>|===))
        (?P<version>
            (?:
                # The identity operators allow for an escape hatch that will
                # do an exact string match of the version you wish to install.
                # This will not be parsed by PEP 440 and we cannot determine
                # any semantic meaning from it. This operator is discouraged
                # but included entirely as an escape hatch.
                (?<====)  # Only match for the identity operator
                \s*
                [^\s]*    # We just match everything, except for whitespace
                          # since we are only testing for strict identity.
            )
            |
            (?:
                # The (non)equality operators allow for wild card and local
                # versions to be specified so we have to define these two
                # operators separately to enable that.
                (?<===|!=)            # Only match for equals and not equals

                \s*
                v?
                (?:[0-9]+!)?          # epoch
                [0-9]+(?:\.[0-9]+)*   # release
                (?:                   # pre release
                    [-_\.]?
                    (a|b|c|rc|alpha|beta|pre|preview)
                    [-_\.]?
                    [0-9]*
                )?
                (?:                   # post release
                    (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                )?

                # You cannot use a wild card and a dev or local version
                # together so group them with a | and make them optional.
                (?:
                    (?:[-_\.]?dev[-_\.]?[0-9]*)?         # dev release
                    (?:\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*)? # local
                    |
                    \.\*  # Wild card syntax of .*
                )?
            )
            |
            (?:
                # The compatible operator requires at least two digits in the
                # release segment.
                (?<=~=)               # Only match for the compatible operator

                \s*
                v?
                (?:[0-9]+!)?          # epoch
                [0-9]+(?:\.[0-9]+)+   # release  (We have a + instead of a *)
                (?:                   # pre release
                    [-_\.]?
                    (a|b|c|rc|alpha|beta|pre|preview)
                    [-_\.]?
                    [0-9]*
                )?
                (?:                                   # post release
                    (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                )?
                (?:[-_\.]?dev[-_\.]?[0-9]*)?          # dev release
            )
            |
            (?:
                # All other operators only allow a sub set of what the
                # (non)equality operators do. Specifically they do not allow
                # local versions to be specified nor do they allow the prefix
                # matching wild cards.
                (?<!==|!=|~=)         # We have special cases for these
                                      # operators so we want to make sure they
                                      # don't match here.

                \s*
                v?
                (?:[0-9]+!)?          # epoch
                [0-9]+(?:\.[0-9]+)*   # release
                (?:                   # pre release
                    [-_\.]?
                    (a|b|c|rc|alpha|beta|pre|preview)
                    [-_\.]?
                    [0-9]*
                )?
                (?:                                   # post release
                    (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                )?
                (?:[-_\.]?dev[-_\.]?[0-9]*)?          # dev release
            )
        )
        z^\s*z\s*$
compatiblez~=rF   z==rG   z!=rH   z<=rI   z>=rJ   rK   rL   rM   	arbitraryz===c             C   so   d j  t t j d d   t |    d  d   } | d 7} |  j d  | |  on |  j d  | |  S)	N.c             S   s   |  j  d  o |  j  d  S)Npostdev)
startswith)xr   r   r   <lambda>  s   z/Specifier._compare_compatible.<locals>.<lambda>r   z.*z>=z==)joinlist	itertools	takewhile_version_splitr;   )r   rN   r.   prefixr   r   r   _compare_compatible  s    	
zSpecifier._compare_compatiblec             C   s   | j  d  rt t | j  } t | d  d   } t t |   } | d  t |   } t | |  \ } } n' t |  } | j s t | j  } n  | | k S)Nz.*   )endswithr   publicrm   r2   len_pad_versionlocal)r   rN   r.   r   r   r   rO     s    	zSpecifier._compare_equalc             C   s   |  j  | |  S)N)rO   )r   rN   r.   r   r   r   rP     s    zSpecifier._compare_not_equalc             C   s   | t  |  k S)N)r   )r   rN   r.   r   r   r   rQ     s    z"Specifier._compare_less_than_equalc             C   s   | t  |  k S)N)r   )r   rN   r.   r   r   r   rR     s    z%Specifier._compare_greater_than_equalc             C   sX   t  |  } | | k  s d S| j rT | j rT t  | j  t  | j  k rT d Sn  d S)NFT)r   r>   base_version)r   rN   r.   r   r   r   rS     s    zSpecifier._compare_less_thanc             C   s   t  |  } | | k s d S| j rT | j rT t  | j  t  | j  k rT d Sn  | j d  k	 r t  | j  t  | j  k r d Sn  d S)NFT)r   is_postreleaserw   rv   )r   rN   r.   r   r   r   rT     s    zSpecifier._compare_greater_thanc             C   s"   t  |  j   t  |  j   k S)N)r2   lower)r   rN   r.   r   r   r   _compare_arbitrary  s    zSpecifier._compare_arbitraryc             C   sy   |  j  d  k	 r |  j  S|  j \ } } | d
 k ru | d k r_ | j d  r_ | d  d  } n  t |  j ru d Sn  d	 S)N==>=<=~====z.*rp   TF)r{   r|   r}   r~   r   rq   )r-   r,   rr   r
   r>   )r   r%   r&   r   r   r   r     s    zSpecifier.prereleasesc             C   s   | |  _  d  S)N)r-   )r   r   r   r   r   r     s    N)r   r   r   rU   rV   rW   rX   rY   r'   r9   r^   ro   rO   rP   rQ   rR   rS   rT   rz   rD   r   r"   r   r   r   r   r_     s,   ^
#r_   z^([0-9]+)((?:a|b|c|rc)[0-9]+)$c             C   s\   g  } xO |  j  d  D]> } t j |  } | rG | j | j    q | j |  q W| S)Nrb   )split_prefix_regexr(   extendgroupsr?   )r&   resultr   r/   r   r   r   rm   '  s    rm   c          	   C   s1  g  g  } } | j  t t j d d   |     | j  t t j d d   |    | j  |  t | d  d    | j  | t | d  d    | j d d g t d t | d  t | d    | j d d g t d t | d  t | d    t t j |    t t j |    f S)Nc             S   s
   |  j    S)N)isdigit)rf   r   r   r   rg   6  s    z_pad_version.<locals>.<lambda>c             S   s
   |  j    S)N)r   )rf   r   r   r   rg   7  s    r   r   0)r?   rj   rk   rl   rt   insertmaxchain)leftright
left_splitright_splitr   r   r   ru   2  s    %%!!//ru   c               @   s   e  Z d  Z d d d d  Z d d   Z d d   Z d	 d
   Z d d   Z d d   Z d d   Z	 d d   Z
 d d   Z e d d    Z e j d d    Z d d   Z d d d  Z d d d  Z d S)SpecifierSetr$   Nc             C   s   d d   | j  d  D } t   } xM | D]E } y | j t |   Wq, t k
 rp | j t |   Yq, Xq, Wt |  |  _ | |  _ d  S)Nc             S   s(   g  |  ] } | j    r | j     q Sr   )r+   ).0sr   r   r   
<listcomp>R  s   	 z)SpecifierSet.__init__.<locals>.<listcomp>,)	r   setaddr_   r   rE   	frozenset_specsr-   )r   
specifiersr   parsed	specifierr   r   r   r0   O  s    	zSpecifierSet.__init__c             C   s=   |  j  d  k	 r! d j |  j  n d } d j t |   |  S)Nz, prereleases={0!r}r$   z<SpecifierSet({0!r}{1})>)r-   r)   r   r2   )r   r3   r   r   r   r4   d  s    !zSpecifierSet.__repr__c             C   s#   d j  t d d   |  j D   S)Nr   c             s   s   |  ] } t  |  Vq d  S)N)r2   )r   r   r   r   r   	<genexpr>n  s    z'SpecifierSet.__str__.<locals>.<genexpr>)ri   sortedr   )r   r   r   r   r   m  s    zSpecifierSet.__str__c             C   s   t  |  j  S)N)r5   r   )r   r   r   r   r   p  s    zSpecifierSet.__hash__c             C   s   t  | t  r t |  } n t  | t  s1 t St   } t |  j | j B | _ |  j d  k r | j d  k	 r | j | _ nZ |  j d  k	 r | j d  k r |  j | _ n- |  j | j k r |  j | _ n t d   | S)NzFCannot combine SpecifierSets with True and False prerelease overrides.)r6   r   r   r7   r   r   r-   
ValueError)r   r   r   r   r   r   __and__s  s    		zSpecifierSet.__and__c             C   se   t  | t  r t |  } n7 t  | t  rB t t |   } n t  | t  sU t S|  j | j k S)N)r6   r   r   r#   r2   r7   r   )r   r   r   r   r   r     s    zSpecifierSet.__eq__c             C   se   t  | t  r t |  } n7 t  | t  rB t t |   } n t  | t  sU t S|  j | j k S)N)r6   r   r   r#   r2   r7   r   )r   r   r   r   r   r     s    zSpecifierSet.__ne__c             C   s   t  |  j  S)N)rt   r   )r   r   r   r   __len__  s    zSpecifierSet.__len__c             C   s   t  |  j  S)N)iterr   )r   r   r   r   __iter__  s    zSpecifierSet.__iter__c             C   s=   |  j  d  k	 r |  j  S|  j s# d  St d d   |  j D  S)Nc             s   s   |  ] } | j  Vq d  S)N)r   )r   r   r   r   r   r     s    z+SpecifierSet.prereleases.<locals>.<genexpr>)r-   r   any)r   r   r   r   r     s
    	zSpecifierSet.prereleasesc             C   s   | |  _  d  S)N)r-   )r   r   r   r   r   r     s    c             C   s   |  j  |  S)N)r   )r   r   r   r   r   r=     s    zSpecifierSet.__contains__c                ss   t    t t f  s$ t      n   d  k r< |  j  n   rP   j rP d St    f d d   |  j D  S)NFc             3   s$   |  ] } | j    d   Vq d S)r   N)r   )r   r   )r   r   r   r   r     s   z(SpecifierSet.contains.<locals>.<genexpr>)r6   r	   r   r
   r   r>   allr   )r   r   r   r   )r   r   r   r     s    zSpecifierSet.containsc             C   s  | d  k r |  j  } n  |  j rT x, |  j D]! } | j | d t |  } q+ W| Sg  } g  } x | D]{ } t | t t f  s t |  } n | } t | t  r qg n  | j r | r | s | j	 |  q qg | j	 |  qg W| r| r| d  k r| S| Sd  S)Nr   )
r   r   r   boolr6   r	   r   r
   r>   r?   )r   r   r   r.   filteredrA   r   rC   r   r   r   r     s*    	zSpecifierSet.filter)r   r   r   r0   r4   r   r   r   r   r   r   r   rD   r   r"   r=   r   r   r   r   r   r   r   M  s   	

r   )
__future__r   r   r   r   r\   rk   rV   _compatr   r   r&   r   r	   r
   r   r   ABCMetaobjectr   r#   rE   r^   r_   rW   r   rm   ru   r   r   r   r   r   <module>   s"   "94	 