3

U'ícžuã@sžddlZddlZddlZddlZddlZddlmZmZmZm	Z	m
Z
mZmZm
Z
mZmZmZddlmZddlmZmZmZeeefZeeeefZededZeeegefZGdd	„d	eƒZGd
d„dejdZ Gd
d„de ƒZ!Gdd„de!ƒZ"edeegefedeegefdœdd„Z#Gdd„de!ƒZ$ej%dƒZ&ee
edœdd„Z'eedœdd„Z(e
ee
eee
ee
efdœdd„Z)Gd d!„d!e ƒZ*dS)"éN)ÚCallableÚDictÚIterableÚIteratorÚListÚOptionalÚPatternÚSetÚTupleÚTypeVarÚUnioné)Úcanonicalize_version)Ú
LegacyVersionÚVersionÚparseÚVersionTypeVar)Zboundc@seZdZdZdS)ÚInvalidSpecifierzH
    An invalid specifier was found, users should refer to PEP 440.
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__©rrú9/tmp/pip-build-gk9425m9/packaging/packaging/specifiers.pyr!src@s¼eZdZejedœdd„ƒZejedœdd„ƒZeje	e
dœdd„ƒZeje
e
dœd	d
„ƒZeje
ddœd
d
„ƒZejdee
e
e
dœdd„ƒZejdeee
e
eedœdd„ƒZdS)Ú
BaseSpecifier)ÚreturncCsdS)zŽ
        Returns the str representation of this Specifier like object. This
        should be representative of the Specifier itself.
        Nr)ÚselfrrrÚ__str__(szBaseSpecifier.__str__cCsdS)zF
        Returns a hash value for this Specifier like object.
        Nr)rrrrÚ__hash__/szBaseSpecifier.__hash__)ÚotherrcCsdS)zq
        Returns a boolean representing whether or not the two Specifier like
        objects are equal.
        Nr)rrrrrÚ__eq__5szBaseSpecifier.__eq__cCsdS)zg
        Returns whether or not pre-releases as a whole are allowed by this
        specifier.
        Nr)rrrrÚprereleases<szBaseSpecifier.prereleasesN)ÚvaluercCsdS)zd
        Sets whether or not pre-releases as a whole are allowed by this
        specifier.
        Nr)rr"rrrr!Cs)Úitemr!rcCsdS)zR
        Determines if the given item is contained within this specifier.
        Nr)rr#r!rrrÚcontainsJszBaseSpecifier.contains)Úiterabler!rcCsdS)z•
        Takes an iterable of items and filters them so that only items which
        are contained within this specifier are allowed in it.
        Nr)rr%r!rrrÚfilterPszBaseSpecifier.filter)N)N)rrrÚabcÚabstractmethodÚstrrÚintrÚobjectÚboolr Úabstractpropertyrr!Úsetterr$rrr&rrrrr'sr)Ú	metaclassc@sJeZdZUiZeeefeed)eee	ddœdd„Z
edœdd„Zedœd	d
„Ze
eeefdœdd„ƒZedœd
d„Zee	dœdd„Zeedœdd„Zeedœdd„Ze
edœdd„ƒZe
edœdd„ƒZe
ee	dœdd„ƒZeje	ddœdd„ƒZee	d œd!d"„Zd*eee	e	d#œd$d%„Zd+ee ee	ee d&œd'd(„Z!dS),Ú_IndividualSpecifierÚN)Úspecr!rcCsH|jj|ƒ}|s td|›dƒ‚|jdƒjƒ|jdƒjƒf|_||_dS)NzInvalid specifier: 'ú'ÚoperatorÚversion)Ú_regexÚsearchrÚgroupÚstripÚ_specÚ_prereleases)rr2r!ÚmatchrrrÚ__init___sz_IndividualSpecifier.__init__)rcCs8|jdk	rd|j›nd}d|jj›dt|ƒ›|›dS)Nz, prereleases=r1ú<ú(z)>)r;r!Ú	__class__rr))rÚprerrrÚ__repr__lsz_IndividualSpecifier.__repr__cCsdj|jŽS)Nz{}{})Úformatr:)rrrrrusz_IndividualSpecifier.__str__cCs|jdt|jdƒfS)Nrr
)r:r)rrrrÚ_canonical_specxsz$_IndividualSpecifier._canonical_speccCs
t|jƒS)N)ÚhashrD)rrrrr|sz_IndividualSpecifier.__hash__)rrcCsPt|tƒr4y|jt|ƒƒ}WqDtk
r0tSXnt||jƒsDtS|j|jkS)N)Ú
isinstancer)r@rÚNotImplementedrD)rrrrrr s
z_IndividualSpecifier.__eq__)ÚoprcCst|d|j|›ƒ}|S)NZ	_compare_)ÚgetattrÚ
_operators)rrHÚoperator_callablerrrÚ
_get_operatorŠsz"_IndividualSpecifier._get_operator)r5rcCst|ttfƒst|ƒ}|S)N)rFrrr)rr5rrrÚ_coerce_versionsz$_IndividualSpecifier._coerce_versioncCs
|jdS)Nr)r:)rrrrr4•sz_IndividualSpecifier.operatorcCs
|jdS)Nr
)r:)rrrrr5™sz_IndividualSpecifier.versioncCs|jS)N)r;)rrrrr!sz _IndividualSpecifier.prereleases)r"rcCs
||_dS)N)r;)rr"rrrr!¡s)r#rcCs
|j|ƒS)N)r$)rr#rrrÚ__contains__¥sz!_IndividualSpecifier.__contains__)r#r!rcCs@|dkr|j}|j|ƒ}|jr(|r(dS|j|jƒ}|||jƒS)NF)r!rMÚ
is_prereleaserLr4r5)rr#r!Znormalized_itemrKrrrr$¨s
z_IndividualSpecifier.contains)r%r!rccsŒd}g}d|dk	r|ndi}xL|D]D}|j|ƒ}|j|f|Žr"|jr\|pL|jr\|j|ƒq"d}|Vq"W|rˆ|rˆx|D]
}|VqzWdS)NFr!T)rMr$rOr!Úappend)rr%r!ÚyieldedÚfound_prereleasesÚkwr5Úparsed_versionrrrr&¿s




z_IndividualSpecifier.filter)r1N)N)N)"rrrrJrr)rr6rr,r=rBrÚpropertyr
rDr*rr+r ÚCallableOperatorrLÚUnparsedVersionÚ
ParsedVersionrMr4r5r!r.rNr$rrr&rrrrr0Zs0

	
r0csÚeZdZdZejdedejejBƒZdddddd	d
œZ	d e
eedd
œ‡fdd„
Z
eedœdd„Zee
edœdd„Zee
edœdd„Zee
edœdd„Zee
edœdd„Zee
edœdd„Zee
edœdd„Z‡ZS)!Ú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*$ÚequalÚ	not_equalÚless_than_equalÚgreater_than_equalÚ	less_thanÚgreater_than)z==z!=z<=z>=r>ú>r1N)r2r!rcstƒj||ƒtjdtƒdS)NzZCreating a LegacyVersion has been deprecated and will be removed in the next major release)Úsuperr=ÚwarningsÚwarnÚDeprecationWarning)rr2r!)r@rrr=üszLegacySpecifier.__init__)r5rcCst|tƒstt|ƒƒ}|S)N)rFrr))rr5rrrrMs
zLegacySpecifier._coerce_version)Úprospectiver2rcCs||j|ƒkS)N)rM)rrer2rrrÚ_compare_equal
szLegacySpecifier._compare_equalcCs||j|ƒkS)N)rM)rrer2rrrÚ_compare_not_equal
sz"LegacySpecifier._compare_not_equalcCs||j|ƒkS)N)rM)rrer2rrrÚ_compare_less_than_equalsz(LegacySpecifier._compare_less_than_equalcCs||j|ƒkS)N)rM)rrer2rrrÚ_compare_greater_than_equalsz+LegacySpecifier._compare_greater_than_equalcCs||j|ƒkS)N)rM)rrer2rrrÚ_compare_less_thansz"LegacySpecifier._compare_less_thancCs||j|ƒkS)N)rM)rrer2rrrÚ_compare_greater_thansz%LegacySpecifier._compare_greater_than)r1N)rrrÚ
_regex_strÚreÚcompileÚVERBOSEÚ
IGNORECASEr6rJr)rr,r=rWrrMrfrgrhrirjrkÚ
__classcell__rr)r@rrYãs"	rYÚ	Specifier)Úfnrcs&tjˆƒdtttdœ‡fdd„ƒ}|S)Nrr)rrer2rcst|tƒsdSˆ|||ƒS)NF)rFr)rrer2)rsrrÚwrapped"s
z)_require_version_compare.<locals>.wrapped)Ú	functoolsÚwrapsrXr)r,)rsrtr)rsrÚ_require_version_comparesrwc	@seZdZdZejdedejejBƒZdddddd	d
ddœZ	e
eee
d
œdd„ƒZe
eee
d
œdd„ƒZe
eee
d
œdd„ƒZe
eee
d
œdd„ƒZe
eee
d
œdd„ƒZe
eee
dœdd„ƒZe
eee
dœdd„ƒZeee
d
œdd„Zee
dœd d!„ƒZeje
d"d#œd$d!„ƒZd"S)%rra
        (?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*$Ú
compatiblerZr[r\r]r^r_Ú	arbitrary)z~=z==z!=z<=z>=r>r`z===)rer2rcCsJdjttjtt|ƒƒƒdd…ƒ}|d7}|jdƒ||ƒoH|jdƒ||ƒS)NÚ.r
z.*z>=z==éÿÿÿÿ)ÚjoinÚlistÚ	itertoolsÚ	takewhileÚ_is_not_suffixÚ_version_splitrL)rrer2ÚprefixrrrÚ_compare_compatible—s
zSpecifier._compare_compatiblec	Csz|jdƒrVt|jƒ}t|dd…ƒ}tt|ƒƒ}|dt|ƒ…}t||ƒ\}}||kSt|ƒ}|jsnt|jƒ}||kSdS)Nz.*ééþÿÿÿ)ÚendswithrÚpublicrr)ÚlenÚ_pad_versionÚlocal)	rrer2Z
split_specZsplit_prospectiveZshortened_prospectiveZpadded_specZpadded_prospectiveZspec_versionrrrrf­s


zSpecifier._compare_equalcCs|j||ƒS)N)rf)rrer2rrrrgÕszSpecifier._compare_not_equalcCst|jƒt|ƒkS)N)rr‡)rrer2rrrrhÙsz"Specifier._compare_less_than_equalcCst|jƒt|ƒkS)N)rr‡)rrer2rrrriász%Specifier._compare_greater_than_equal)reÚspec_strrcCs>t|ƒ}||ksdS|jr:|jr:t|jƒt|jƒkr:dSdS)NFT)rrOÚbase_version)rrer‹r2rrrrjëszSpecifier._compare_less_thancCs`t|ƒ}||ksdS|jr:|jr:t|jƒt|jƒkr:dS|jdk	r\t|jƒt|jƒkr\dSdS)NFT)rÚis_postreleaserŒrŠ)rrer‹r2rrrrks
zSpecifier._compare_greater_thancCst|ƒjƒt|ƒjƒkS)N)r)Úlower)rrer2rrrÚ_compare_arbitrary%szSpecifier._compare_arbitrary)rcCsR|jdk	r|jS|j\}}|d
krN|dkr@|jdƒr@|dd…}t|ƒjrNdSd	S)Nú==ú>=ú<=ú~=ú===z.*r„TF)rr‘r’r“r”r…)r;r:r†rrO)rr4r5rrrr!(s


zSpecifier.prereleasesN)r"rcCs
||_dS)N)r;)rr"rrrr!As)rrrrlrmrnrorpr6rJrwrXr)r,rƒrfrgrhrirjrkrrrUr!r.rrrrrr+s<]'z^([0-9]+)((?:a|b|c|rc)[0-9]+)$)r5rcCsDg}x:|jdƒD],}tj|ƒ}|r2|j|jƒƒq|j|ƒqW|S)Nrz)ÚsplitÚ
_prefix_regexr7ÚextendÚgroupsrP)r5Úresultr#r<rrrrIs
r)Úsegmentrcst‡fdd„dDƒƒS)	Nc3s|]}ˆj|ƒVqdS)N)Ú
startswith)Ú.0r‚)ršrrú	<genexpr>Vsz!_is_not_suffix.<locals>.<genexpr>ÚdevÚaÚbÚrcÚpost)ržrŸr r¡r¢)Úany)ršr)ršrr€Tsr€)ÚleftÚrightrc	Csægg}}|jttjdd„|ƒƒƒ|jttjdd„|ƒƒƒ|j|t|dƒd…ƒ|j|t|dƒd…ƒ|jddgtdt|dƒt|dƒƒƒ|jddgtdt|dƒt|dƒƒƒttj|Žƒttj|ŽƒfS)NcSs|jƒS)N)Úisdigit)ÚxrrrÚ<lambda>^sz_pad_version.<locals>.<lambda>cSs|jƒS)N)r¦)r§rrrr¨_srr
Ú0)rPr}r~rrˆÚinsertÚmaxÚchain)r¤r¥Ú
left_splitÚright_splitrrrr‰Zs
,,r‰c@s
eZdZd#eeeddœdd„Zedœdd„Zedœd	d
„Ze	dœdd„Z
edefdd
œdd„Ze
ed
œdd„Ze	dœdd„Zeedœdd„Zeeedœdd„ƒZejeddœdd„ƒZeedœdd„Zd$eeeedœdd„Zd%eeeeeed œd!d"„ZdS)&ÚSpecifierSetr1N)Ú
specifiersr!rcCsrdd„|jdƒDƒ}tƒ}xB|D]:}y|jt|ƒƒWq tk
rX|jt|ƒƒYq Xq Wt|ƒ|_||_dS)NcSsg|]}|jƒr|jƒ‘qSr)r9)rœÚsrrrú
<listcomp>ssz)SpecifierSet.__init__.<locals>.<listcomp>ú,)	r•ÚsetÚaddrrrrYÚ	frozensetÚ_specsr;)rr°r!Zsplit_specifiersÚparsedÚ	specifierrrrr=ms

zSpecifierSet.__init__)rcCs.|jdk	rd|j›nd}dt|ƒ›|›dS)Nz, prereleases=r1z<SpecifierSet(z)>)r;r!r))rrArrrrB…szSpecifierSet.__repr__cCsdjtdd„|jDƒƒƒS)Nr³css|]}t|ƒVqdS)N)r))rœr±rrrrsz'SpecifierSet.__str__.<locals>.<genexpr>)r|Úsortedr·)rrrrrŽszSpecifierSet.__str__cCs
t|jƒS)N)rEr·)rrrrr‘szSpecifierSet.__hash__)rrcCs˜t|tƒrt|ƒ}nt|tƒs"tStƒ}t|j|jBƒ|_|jdkrX|jdk	rX|j|_n<|jdk	rv|jdkrv|j|_n|j|jkrŒ|j|_ntdƒ‚|S)NzFCannot combine SpecifierSets with True and False prerelease overrides.)rFr)r¯rGr¶r·r;Ú
ValueError)rrr¹rrrÚ__and__”s





zSpecifierSet.__and__cCs6t|ttfƒrtt|ƒƒ}nt|tƒs*tS|j|jkS)N)rFr)r0r¯rGr·)rrrrrr «s

zSpecifierSet.__eq__cCs
t|jƒS)N)rˆr·)rrrrÚ__len__³szSpecifierSet.__len__cCs
t|jƒS)N)Úiterr·)rrrrÚ__iter__¶szSpecifierSet.__iter__cCs.|jdk	r|jS|jsdStdd„|jDƒƒS)Ncss|]}|jVqdS)N)r!)rœr±rrrrÉsz+SpecifierSet.prereleases.<locals>.<genexpr>)r;r·r£)rrrrr!¹s

zSpecifierSet.prereleases)r"rcCs
||_dS)N)r;)rr"rrrr!Ës)r#rcCs
|j|ƒS)N)r$)rr#rrrrNÏszSpecifierSet.__contains__)r#r!rcsNtˆttfƒstˆƒ‰ˆdkr$|j‰ˆr4ˆjr4dSt‡‡fdd„|jDƒƒS)NFc3s|]}|jˆˆdVqdS))r!N)r$)rœr±)r#r!rrrísz(SpecifierSet.contains.<locals>.<genexpr>)rFrrrr!rOÚallr·)rr#r!r)r#r!rr$ÒszSpecifierSet.contains)r%r!rcCs¼|dkr|j}|jr:x |jD]}|j|t|ƒd}qW|Sg}g}xZ|D]R}t|ttfƒsdt|ƒ}n|}t|tƒrtqH|jr|r|sš|j	|ƒqH|j	|ƒqHW|r´|r´|dkr´|S|SdS)N)r!)
r!r·r&r,rFrrrrOrP)rr%r!r2ÚfilteredrRr#rTrrrr&ïs*


zSpecifierSet.filter)r1N)N)N)rrrr)rr,r=rBrr*rrr¼r+r r½rr0r¿rUr!r.rWrNr$rrr&rrrrr¯ls$
	
r¯)+r'rur~rmrbÚtypingrrrrrrrr	r
rrÚutilsrr5rrrrXr)rWrr,rVr»rÚABCMetarr0rYrwrrrnr–rr€r‰r¯rrrrÚ<module>s443
=

*