ó îaNc@sddlZddlZddlZddlZddlmZdZdZdZdZ dZ dZ dZ dZ d Zd efd „ƒYZd efd „ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdS(iÿÿÿÿN(tizipii2idieifiÈi,t VersionErrorcBseZdZd„ZRS(s,Base exception class for all version errors.cGstj||ŒdS(N(t Exceptiont__init__(tselftargs((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR2s(t__name__t __module__t__doc__R(((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR/stIllegalDotSequencecBseZdZRS(s=Used to indicate that the specified DotSequence is not valid.(RRR(((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR 6st DotSequencecBsheZdZejƒZed„ƒZd„Zd„Z d„Z d„Z d„Z d„Z d„ZRS( sÅA DotSequence is the typical "x.y.z" string used in software versioning. We define the "major release" value and the "minor release" value as the first two numbers in the sequence.cCsTt|ƒ}|ddkr(td‚n|dkrP|ddkrPtd‚n|S(Nit-sNegative numbert0sZero padded number(tintt ValueError(telemtx((s1/usr/lib/python2.7/vendor-packages/pkg/version.pytdotsequence_valEs    cCs?tjj|ƒ}|dkr;tj|ƒ|j|<}n|S(N(R t_DotSequence__dotseq_pooltgettNonetlistt__new__(tclst dotstringtds((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyRPs cCs„t|ƒdkrdSy)tj|ttj|jdƒƒƒWntk r^t|ƒ‚nXt|ƒdkr€tdƒ‚ndS(Nit.sEmpty DotSequence( tlenRRtmapR RtsplitRR (RR((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyRWs   cCsdjtt|ƒƒS(NR(tjoinRtstr(R((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyt__str__fscCstt|ƒƒS(N(thashttuple(R((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyt__hash__iscCsPt|ƒt|ƒkrtSx-t||ƒD]\}}||kr,tSq,WtS(s¬Return true if self is a "subsequence" of other, meaning that other and self have identical components, up to the length of self's sequence.(RtFalseRtTrue(Rtothertatb((s1/usr/lib/python2.7/vendor-packages/pkg/version.pytis_subsequencels  cCs|d|dkS(s1 Test if DotSequences have the same major number i((RR&((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyt is_same_majoryscCs&|d|dko%|d|dkS(s8 Test if DotSequences have the same major and minor num ii((RR&((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyt is_same_minor}s(RRRtweakreftWeakValueDictionaryRt staticmethodRRRR R#R)R*R+(((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR 9s      tMatchingDotSequencecBsheZdZejƒZed„ƒZd„Zd„Z d„Z d„Z d„Z d„Z d„ZRS( sŒA subclass of DotSequence with (much) weaker rules about its format. This is intended to accept user input with wildcard characters.cCs|dkr|Stj|ƒS(Nt*(R R(R((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyRs cCsEtjj|dƒ}|dk r%|Stj|ƒ}||j|<|S(N(R/t*_MatchingDotSequence__matching_dotseq_poolRRRR(RRR((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR–s    cCsny)tj|t|j|jdƒƒƒWntk rHt|ƒ‚nXt|ƒdkrjtdƒ‚ndS(NRisEmpty MatchingDotSequence(RRRRRRR R(RR((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR s   cCsõt|tƒstSt|ƒ}t|ƒ}xÃtt||ƒƒD]¬}y6||||kr|d||||fkr|tSWqAtk rì||dkr»d|d||fkr»tS||dkríd|||dfkrítSqAXqAWtS(NR0iiÿÿÿÿ(t isinstanceR R%Rtrangetmaxt IndexErrorR$(RR&tlstloti((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyt__ne__«s"    cCsõt|tƒstSt|ƒ}t|ƒ}xÃtt||ƒƒD]¬}y6||||kr|d||||fkr|tSWqAtk rì||dkr»d|d||fkr»tS||dkríd|||dfkrítSqAXqAWtS(NR0iiÿÿÿÿ(R2R R$RR3R4R5R%(RR&R6R7R8((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyt__eq__¿s"    cCsxt|ƒdks$t|ƒdkr(tSt|ƒt|ƒkrDtSx-t||ƒD]\}}||krTtSqTWtS(sÄReturn true if self is a "subsequence" of other, meaning that other and self have identical components, up to the length of self's sequence or self or other is '*'.R0(RR%RR$R(RR&R'R(((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR)Ós$ cCs2|ddkp1|ddkp1|d|dkS(sQTest if DotSequences have the same major number, or major is '*'.iR0((RR&((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR*ãscCsf|ddkpe|ddkpe|ddkpe|ddkpe|d|dkoe|d|dkS(s8 Test if DotSequences have the same major and minor num.iR0i((RR&((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR+ès0(RRRR,R-R1R.RRRR9R:R)R*R+(((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR/‚s     tIllegalVersioncBseZdZRS(s@Used to indicate that the specified version string is not valid.(RRR(((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR;ïstVersioncBsÝeZdZddddgZd„Zedd„ƒZedd„ƒZd„Z d „Z d „Z d „Z e j jƒd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zed„ƒZRS(sÔVersion format is release[,build_release]-branch:datetime, which we decompose into three DotSequences and a date string. Time representation is in the ISO8601-compliant form "YYYYMMDDTHHMMSSZ", referring to the UTC time associated with the version. The release and branch DotSequences are interpreted normally, where v1 < v2 implies that v2 is a later release or branch. The build_release DotSequence records the system on which the package binaries were constructed. Interpretation of the build_release by the client is that, in the case b1 < b2, a b1 package can be run on either b1 or b2 systems,while a b2 package can only be run on a b2 system.treleasetbrancht build_releasettimestrc Cst|std‚n|jdƒ}|dkr>||d}n d}d}|jdƒ}|dkry||d|!}n |}d}|jdƒ}|dkr´||d|!}n |}d}|dkrØtd‚nyt|| ƒ|_|dk r t|ƒ|_n d|_|dk r3t|ƒ|_n4|dkrXtd ||fƒ‚nt|ƒ|_Wn#tk r} td | ƒ‚nX|dk rgt|ƒd ksÌ|d d ksÌ|ddkrØtd‚nyft |dd !ƒ} t |dd!ƒ} t j | d| dd| d| d| dd| dƒWnt k rZtd‚nX||_ n d|_ dS(NsVersion cannot be emptyt:iÿÿÿÿiR t,is"Versions must have a release values:No build version provided in Version constructor: (%s, %s)sBad Version: %siitTitZsTime must be ISO8601 format.i i'id( R;tfindRR R=R>R?R RR tdatetimeRR@( Rtversion_stringt build_stringttimeidxR@t branchidxR>tbuildidxtbuildtetdateintttimeint((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyRsj           "       cCs t|ƒS(sReturns the serialized state of this object in a format that that can be easily stored using JSON, pickle, etc.(R(tobjtje_state((s1/usr/lib/python2.7/vendor-packages/pkg/version.pytgetstate_scCs t|dƒS(s`Allocate a new object using previously serialized state obtained via getstate().N(R<R(tstatetjd_state((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyt fromstateescCs|j|krtStS(s.target is a DotSequence for the target system.(R?R%R$(Rttarget((s1/usr/lib/python2.7/vendor-packages/pkg/version.pytcompatible_with_buildkscCsdt|jƒdt|jƒ}|jrC|dt|jƒ7}n|jr`|d|j7}n|S(NRBR RA(RR=R?R>R@(Rtoutstr((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR qs    cCsd|t|ƒfS(Ns(tid(R((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyt__repr__yscCs6d}|jdk r%d|j}nd|j|fS(Nts-%ss%s%s(R>RR=(Rt branch_str((s1/usr/lib/python2.7/vendor-packages/pkg/version.pytget_short_version|scCs[t|ƒtjkst‚|jƒdksE|jƒdksEt‚|jdƒ|_dS(NtUTCs%Y%m%dT%H%M%SZ(ttypeRFtAssertionErrorttznameRtstrftimeR@(Rt timestamp((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyt set_timestamp‚s*cCs;|js dStj|jdƒ}tjjtj|ƒƒS(Ns%Y%m%dT%H%M%SZ(R@RttimetstrptimeRFtutcfromtimestamptcalendarttimegm(Rtt((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyt get_timestamp‡s cCsQt|tƒstS|j|jkrM|j|jkrM|j|jkrMtStS(N(R2R<R%R=R>R@R$(RR&((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR9scCsQt|tƒstS|j|jkrM|j|jkrM|j|jkrMtStS(N(R2R<R$R=R>R@R%(RR&((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR:—scCs{t|tƒstS|j|jkr)tS|j|jkr?tS|j|jkrUtS|j|jkrktS|j|jkS(s Returns True if 'self' comes before 'other', and vice versa. If exactly one of the release values of the versions is None, then that version is less than the other. The same applies to the branch and timestamp components. (R2R<R$R=R%R>R@(RR&((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyt__lt__¡scCs{t|tƒstS|j|jkr)tS|j|jkr?tS|j|jkrUtS|j|jkrktS|j|jkS(sReturns True if 'self' comes after 'other', and vice versa. If exactly one of the release values of the versions is None, then that version is less than the other. The same applies to the branch and timestamp components. (R2R<R%R=R$R>R@(RR&((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyt__gt__·scCsP||krdS||kr dS|j|jkr6dS|j|jkrLdSdS(Niÿÿÿÿii(R?(RR&((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyt__cmp__Ís  cCs0|jrt|jƒSt|j|jfƒSdS(N(R@R!R=R>(R((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR#Ùs  cCsÅ|dks|tkr"||kS|tkr@t|ƒtkr@|jrn|jrn|jj|jƒstSn"|jrt|jƒdkrtS|j r¾|j r¾|j j|j ƒsàtSn"|j ràt|j ƒdkràtS|j r|j r|j |j kp|j dks<tSn"|j r<t|j ƒdkr<tSt S|tkrþ|jrz|jrz|jj|jƒs‡tSn |jr‡tS|j rµ|j rµ|j j|j ƒsÂtSn |j rÂtS|j rí|j rí|j |j krútSn |j rútSt S|t kr|jj|jƒS|t kr<|jj|jƒS|tkr[|jj|jƒS|tkrz|j j|j ƒS|tkr™|j j|j ƒS|tkr¸|j j|j ƒStd‚dS(s;Evaluate true if self is a successor version to other. The loosest constraint is CONSTRAINT_NONE (None is treated equivalently, which is a simple test for self > other. As we proceed through the policies we get stricter, depending on the selected constraint. Slightly less loose is CONSTRAINT_AUTO. In this case, if any of the release, branch, or timestamp components is None, it acts as a "don't care" value -- a versioned component always succeeds None. For CONSTRAINT_RELEASE, self is a successor to other if all of the components of other's release match, and there are later components of self's version. The branch and datetime components are ignored. For CONSTRAINT_RELEASE_MAJOR and CONSTRAINT_RELEASE_MINOR, other is effectively truncated to [other[0]] and [other[0], other[1]] prior to being treated as for CONSTRAINT_RELEASE. Similarly for CONSTRAINT_BRANCH, the release fields of other and self are expected to be identical, and then the branches are compared as releases were for the CONSTRAINT_RELEASE* policies. R0sconstraint has unknown valueN(RtCONSTRAINT_NONEtCONSTRAINT_AUTOR_tMatchingVersionR=R)R$RR>R@R%tCONSTRAINT_RELEASEtCONSTRAINT_RELEASE_MAJORR*tCONSTRAINT_RELEASE_MINORR+tCONSTRAINT_BRANCHtCONSTRAINT_BRANCH_MAJORtCONSTRAINT_BRANCH_MINORR(RR&t constraint((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyt is_successorâsj                c Cs |jdƒ}|dkr,||d}n d}d}|jdƒ}|dkrg||d|!}n |}d}|jdƒ}|dkr¢||d|!}n |}d}|| }d} |dk rÓ|} n|dk rð|d|} n|} || ||f| fS(s¶Takes an assumed valid version string and splits it into its components as a tuple of the form ((release, build_release, branch, timestr), short_ver).RAiÿÿÿÿiR RBR[N(RER( RtverRIR@RJR>RKRLR=R?t short_ver((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyRAs.       N(RRRt __slots__RR.RRRRURWR RZR]RFtutcnowRdRkR9R:RlRmRnR#Ryt classmethodR(((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR<òs*  _        _RqcBsbeZdZddgZd„Zd„Zd„Zd„Zd„Zd„Z d „Z d „Z RS( sAn alternative for Version with (much) weaker rules about its format. This is intended to accept user input with globbing characters.t match_latestt __originalc Cs»|dkst|ƒ r%td‚n|dkrCt|_d}n t|_|j|ƒ\\}}}}}|s||}nyx–d|ffd|dffd|dffd|dfffD]U\}} xF| D]>} | säqÒn|dkrÿt| ƒ} nt||| ƒPqÒWq¿WWn#t k r>} td| ƒ‚nXt |ƒ} |dk rn| d t |ƒ7} n|dk r‘| d t |ƒ7} n|dk r®| d |7} n| |_ dS( NsVersion cannot be emptytlatestR0R=R?R>R@sBad Version: %sRBR RA( RRR;R%RR$RR/tsetattrR Rt_MatchingVersion__original( RRGRHR=R?R>R@tignoredtattrtvalstvalRMRX((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyRss@     !         cCs|jr dS|jS(NR(RRƒ(R((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR ¨s cCs |jdkrdStj|ƒS(NR0(R@R<Rk(R((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyRk­scCs{t|tƒstS|j|jkrw|j|jkrw|j|jkrw|j|jkssd|j|jfkrwtStS(NR0(R2R<R%R=R?R>R@R$(RR&((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR9²scCs{t|tƒstS|j|jkrw|j|jkrw|j|jkrw|j|jkssd|j|jfkrwtStS(NR0(R2R<R$R=R?R>R@R%(RR&((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR:¾scCsSt|tƒstSt|jƒdkrAt|jƒdkrAtS|j|jkrWtS|j|jkrmtSt|jƒdkr›t|jƒdkr›tS|j|jkr±tS|j|jkrÇtSt|jƒdkrõt|jƒdkrõtS|j|jkr tS|j|jkr!tS|jdkrC|jdkrCtS|j|jkS(s'Returns True if 'self' comes before 'other', and vice versa. If exactly one of the release values of the versions is None or "*", then that version is less than the other. The same applies to the branch and timestamp components. R0( R2R<R$RR=R%R?R>R@(RR&((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyRlÊs0**cCsSt|tƒstSt|jƒdkrAt|jƒdkrAtS|j|jkrWtS|j|jkrmtSt|jƒdkr›t|jƒdkr›tS|j|jkr±tS|j|jkrÇtSt|jƒdkrõt|jƒdkrõtS|j|jkr tS|j|jkr!tS|jdkrC|jdkrCtS|j|jkS(s&Returns True if 'self' comes after 'other', and vice versa. If exactly one of the release values of the versions is None or "*", then that version is less than the other. The same applies to the branch and timestamp components. R0( R2R<R%RR=R$R?R>R@(RR&((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyRmïs0**cCs?|jr%|jdkr%t|jƒSt|j|jfƒSdS(NR0(R@R!R=R>(R((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyR#s ( RRRR|RR RkR9R:RlRmR#(((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyRqls  5   % %(RhRFReR,t itertoolsRRoRpRrRsRtRuRvRwtCONSTRAINT_SEQUENCERRR RR R/R;tobjectR<Rq(((s1/usr/lib/python2.7/vendor-packages/pkg/version.pyts*    Imÿ{