abc @srdZddlZddlZddlmZddddd d d d gZejeZd e fd YZ de fdYZ de fdYZ ejdZdZeZde fdYZdZde fdYZejddfejddfejddfejddfejddfejd dfejd!d"fejd#d$fejd%d&fejd'd(ff Zejd)dfejd*dfejd+d"fejd!d"fejd,dffZejd-Zd.Zd/Zejd0ejZid1d26d1d36d4d56d1d66d7d86dd6dd"6Zd9Zde fd:YZde fd;YZ ejd<ejZ!d=Z"d>Z#d e fd?YZ$d e fd@YZ%dAe fdBYZ&ie&eeedC6e&ee dDdE6e&e#e%edF6Z'e'dCe'dGtt|dksVtdS(Ni(tstript_stringtparset_partst isinstancettupletAssertionErrortlen(tselftstparts((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt__init__scCstddS(Nsplease implement in a subclass(tNotImplementedError(RR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR$scCs5t|t|kr1td||fndS(Nscannot compare %r and %r(ttypet TypeError(Rtother((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt_check_compatible'scCs|j||j|jkS(N(RR(RR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt__eq__+s cCs|j| S(N(R(RR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt__ne__/scCs|j||j|jkS(N(RR(RR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt__lt__2s cCs|j|p|j| S(N(R R(RR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt__gt__6scCs|j|p|j|S(N(R R(RR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt__le__9scCs|j|p|j|S(N(R!R(RR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt__ge__<scCs t|jS(N(thashR(R((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt__hash__@scCsd|jj|jfS(Ns%s('%s')(t __class__R R(R((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt__repr__CscCs|jS(N(R(R((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt__str__FscCstddS(NsPlease implement in subclasses.(R(R((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt is_prereleaseIs(R R RRRRRR R!R"R#R%R'R(tpropertyR)(((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR s            tMatchercBseZdZejdZejdZejdZidd6dd6dd6d d 6d d 6d d6dd6dd6Z dZ dZ e dZ dZdZdZdZdZdZRS(s^(\w[\s\w'.-]*)(\((.*)\))?s'^(<=|>=|<|>|!=|={2,3}|~=)?\s*([^\s,]+)$s ^\d+(\.\d+)*$cCs ||kS(N((tvtctp((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pytWttcCs||kp||kS(N((R,R-R.((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR/YR0s<=cCs||kp||kS(N((R,R-R.((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR/ZR0s>=cCs ||kS(N((R,R-R.((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR/[R0s==cCs ||kS(N((R,R-R.((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR/\R0s===cCs||kp||kS(N((R,R-R.((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR/^R0s~=cCs ||kS(N((R,R-R.((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR/_R0s!=c Cs|jdkrtdn|j|_}|jj|}|s\td|n|jd}|dj|_|jj |_ g}|drg|dj dD]}|j^q}x|D]}|j j|}|s td||fn|j}|dp#d}|d }|j d r|dkr^td |n|d t}} |jj|s|j|qn|j|t}} |j||| fqWnt||_dS(NsPlease specify a version classs Not valid: %rR0iit,sInvalid %r in %rs~=is.*s==s!=s#'.*' not allowed for %r constraintsi(s==s!=(t version_classtNonet ValueErrorR Rtdist_retmatchtgroupstnametlowertkeytsplittcomp_retendswithtTruetnum_retFalsetappendRR( RRtmR9tclistR-t constraintstoptvntprefix((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyRbs: ,     cCst|tr!|j|}nx|jD]\}}}|jj|}t|trmt||}n|sd||jjf}t |n||||s+t Sq+Wt S(s Check if the provided version matches the constraints. :param version: The version to match against this instance. :type version: String or :class:`Version` instance. s%r not implemented for %s( RRR4Rt _operatorstgettgetattrR&R RRBR@(Rtversiontoperatort constraintRItftmsg((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR8scCsJd}t|jdkrF|jdddkrF|jdd}n|S(Niis==s===(s==s===(R5RR(Rtresult((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt exact_versions,cCsGt|t|ks*|j|jkrCtd||fndS(Nscannot compare %s and %s(RR:R(RR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyRs*cCs/|j||j|jko.|j|jkS(N(RR<R(RR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyRs cCs|j| S(N(R(RR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyRscCst|jt|jS(N(R$R<R(R((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR%scCsd|jj|jfS(Ns%s(%r)(R&R R(R((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR'scCs|jS(N(R(R((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR(sN(R R R5R4tretcompileR7R>RARJRR8R*RSRRRR%R'R((((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR+Ns,         %      sk^v?(\d+!)?(\d+(\.\d+)*)((a|b|c|rc)(\d+))?(\.(post)(\d+))?(\.(dev)(\d+))?(\+([a-zA-Z\d]+(\.[a-zA-Z\d]+)?))?$c CsK|j}tj|}|s4td|n|j}td|djdD}x0t|dkr|ddkr|d }qfW|dsd}nt|d}|dd!}|d d !}|d d !}|d }|dkrd}n|dt|df}|dkr.d}n|dt|df}|dkr]d}n|dt|df}|dkrd}nfg} xQ|jdD]@} | j rdt| f} n d| f} | j | qWt| }|s| r|rd}qd}n|s&d}n|s5d}n||||||fS(NsNot a valid version: %scss|]}t|VqdS(N(tint(t.0R,((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pys sit.iiiiii i i i tatzt_tfinal(NN((NN((NN(((RYi(RZ(R[(R\( R tPEP440_VERSION_RER8RR9RR=RRVR5tisdigitRC( RRDR9tnumstepochtpretposttdevtlocalRtpart((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt _pep_440_keysT  #%                      cBsAeZdZdZedddddgZedZRS(sIA rational version. Good: 1.2 # equivalent to "1.2.0" 1.2.0 1.2a1 1.2.3a2 1.2.3b1 1.2.3c1 1.2.3.4 TODO: fill this out Bad: 1 # minimum two numbers 1.2a # release level must have a release serial 1.2.3b cCsQt|}tj|}|j}td|djdD|_|S(Ncss|]}t|VqdS(N(RV(RWR,((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pys siRX(t_normalized_keyR]R8R9RR=t_release_clause(RRRRRDR9((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyRs   &RYtbR-trcRccstfdjDS(Nc3s(|]}|r|djkVqdS(iN(t PREREL_TAGS(RWtt(R(s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pys s(tanyR(R((Rs?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR)s(R R R RtsetRkR*R)(((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyRs cCsUt|}t|}||kr(tS|j|s;tSt|}||dkS(NRX(tstrR@t startswithRBR(txtytn((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt _match_prefix"s    cBseZeZidd6dd6dd6dd6dd 6d d 6d d 6dd6ZdZdZdZdZdZ dZ dZ dZ dZ RS(t_match_compatibles~=t _match_ltR1t _match_gtR2t _match_les<=t _match_ges>=t _match_eqs==t_match_arbitrarys===t _match_nes!=cCsx|r"d|ko|jd}n|jd o:|jd}|rn|jjddd}|j|}n||fS(Nt+iii(RRR=R4(RRMRORIt strip_localR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt _adjust_local<scCsj|j|||\}}||kr+tS|j}djg|D]}t|^qA}t|| S(NRX(RRBRhtjoinRoRt(RRMRORItrelease_clausetitpfx((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyRvJs   (cCsj|j|||\}}||kr+tS|j}djg|D]}t|^qA}t|| S(NRX(RRBRhRRoRt(RRMRORIRRR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyRwRs   (cCs%|j|||\}}||kS(N(R(RRMRORI((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyRxZscCs%|j|||\}}||kS(N(R(RRMRORI((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyRy^scCsC|j|||\}}|s0||k}nt||}|S(N(RRt(RRMRORIRR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyRzbs cCst|t|kS(N(Ro(RRMRORI((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR{jscCsD|j|||\}}|s0||k}nt|| }|S(N(RRt(RRMRORIRR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR|ms cCs|j|||\}}||kr+tS||kr;tS|j}t|dkrc|d }ndjg|D]}t|^qp}t||S(NiiRX(RR@RBRhRRRoRt(RRMRORIRRR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyRuus    ((R R RR4RJRRvRwRxRyRzR{R|Ru(((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR-s&         s[.+-]$R0s^[.](\d)s0.\1s^[.-]s ^\((.*)\)$s\1s^v(ersion)?\s*(\d+)s\2s^r(ev)?\s*(\d+)s[.]{2,}RXs\b(alfa|apha)\btalphas\b(pre-alpha|prealpha)\bs pre.alphas \(beta\)$tbetas ^[:~._+-]+s [,*")([\]]s[~:+_ -]s\.$s (\d+(\.\d+)*)c Cs|jj}x&tD]\}}|j||}qW|sJd}ntj|}|snd}|}n|jdjd}g|D]}t|^q}x#t |dkr|j dqWt |dkr||j }nDdj g|dD]}t |^q||j }|d }dj g|D]}t |^qB}|j}|rx)tD]\}}|j||}qvWn|s|}n&d|krdnd}|||}t|sd}n|S( s Try to suggest a semantic form for a version for which _suggest_normalized_version couldn't come up with anything. s0.0.0iRXiRct-R}N(R R;t _REPLACEMENTStsubt_NUMERIC_PREFIXR8R9R=RVRRCtendRRot_SUFFIX_REPLACEMENTSt is_semverR5( RRRtpattreplRDRItsuffixRtsep((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt_suggest_semantic_versions:  : (    cCs yt||SWntk r%nX|j}xSd2d3d4d5d6d7d8d9d:d;d<d=d>d?d@fD]\}}|j||}qfWtjdd|}tjdd|}tjdd|}tjdd|}tjdd|}|jdr |d }ntjd!d|}tjd"d#|}tjd$d%|}tjd&d|}tjd'd(|}tjd)d(|}tjd*d |}tjd+d,|}tjd-d%|}tjd.d/|}tjd0d1|}yt|Wntk rdA}nX|S(BsSuggest a normalized version close to the given version string. If you have a version string that isn't rational (i.e. NormalizedVersion doesn't like it) then you might be able to get an equivalent (or close) rational version from this function. This does a number of simple normalizations to the given string, based on observation of versions currently in use on PyPI. Given a dump of those version during PyCon 2009, 4287 of them: - 2312 (53.93%) match NormalizedVersion without change with the automatic suggestion - 3474 (81.04%) match when using this suggestion method @param s {str} An irrational version string. @returns A rational version string, or None, if couldn't determine one. s-alphaRYs-betaRiRRRjR-s-finalR0s-pres-releases.releases-stableR}RXR[t s.finalR\spre$tpre0sdev$tdev0s([abc]|rc)[\-\.](\d+)$s\1\2s[\-\.](dev)[\-\.]?r?(\d+)$s.\1\2s[.~]?([abc])\.?s\1R,is\b0+(\d+)(?!\d)s (\d+[abc])$s\g<1>0s\.?(dev-r|dev\.r)\.?(\d+)$s.dev\2s-(a|b|c)(\d+)$s[\.\-](dev|devel)$s.dev0s(?![\.\-])dev$s(final|stable)$s\.?(r|-|-r)\.?(\d+)$s.post\2s\.?(dev|git|bzr)\.?(\d+)$s\.?(pre|preview|-c)(\d+)$sc\g<2>sp(\d+)$s.post\1(s-alphaRY(s-betaRi(RRY(RRi(RjR-(s-finalR0(s-preR-(s-releaseR0(s.releaseR0(s-stableR0(R}RX(R[RX(RR0(s.finalR0(R\R0N(RgRR;treplaceRTRRpR5(RtrstorigR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt_suggest_normalized_versionsH           s([a-z]+|\d+|[\.-])R-Ratpreviewsfinal-RRjt@RccCsd}g}x||D]}|jdr|dkrgx'|rc|ddkrc|jq@Wnx'|r|ddkr|jqjWn|j|qWt|S(NcSsg}xtj|jD]j}tj||}|rd|d koUdknrl|jd}n d|}|j|qqW|jd|S(Nt0it9it*s*final(t _VERSION_PARTR=R;t_VERSION_REPLACERKtzfillRC(RRRR.((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt get_partsIs   Rs*finalis*final-t00000000(RptpopRCR(RRRRR.((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyt _legacy_keyHs  cBs eZdZedZRS(cCs t|S(N(R(RR((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyRcscCsRt}xE|jD]:}t|tr|jdr|dkrt}PqqW|S(NRs*final(RBRRRRpR@(RRRRq((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyR)fs (R R RR*R)(((s?/usr/lib/python2.7/site-packages/pip/_vendor/distlib/version.pyRbs cBs?eZeZeejZded s~   1k =$ W  . r       #