Nc@suddlZddljZdZdZdZedZdZidd6d d 6Z d Z d Z dS( iNcCsBt|tr.tjd|r.tdfSnttd|fS(sReturns a tuple of (valid, error) indicating whether the provided string is a valid name for a link mediation. 'valid' is a boolean and 'error' is None or a string containing the error.s^[a-zA-Z0-9\-]+$sF'%s' is not a valid mediator; only alphanumeric characters are allowedN(t isinstancet basestringtretmatchtTruetNonetFalset_(tvalue((s2/usr/lib/python2.7/vendor-packages/pkg/mediator.pytvalid_mediators   cCsd}t|tr[ytj|dtdfSWq[tjk rW}t|}q[Xn|rxtt dt fStt d|fS(sReturns a tuple of (valid, error) indicating whether the provided string is a valid mediator version for a link mediation. 'valid' is a boolean and 'error' is None or a string containing the error.ts5.11s6'%(value)s' is not a valid mediator-version: %(error)ss$'%s' is not a valid mediator-versionN( RRtversiontVersionRRt VersionErrortstrRRtlocals(Rterrorte((s2/usr/lib/python2.7/vendor-packages/pkg/mediator.pytvalid_mediator_version(s  cCst|tsdSd|krYy|jdd\}}Wqettfk rUdSXn |}d}|rytj|d}Wqtjk rdSXn||fS(s]Parses the provided mediator implementation string for a link and returns a tuple of (name, version) where 'name' is a string containing the name of the implementation and 'version' is None or a pkg.version object representing the version. If the implementation is not valid a tuple of (None, None) will be returned.t@is5.11N(NN(NN(NN( RRRtrsplitt ValueErrortAttributeErrorR R R (Rt impl_nametimpl_ver((s2/usr/lib/python2.7/vendor-packages/pkg/mediator.pytparse_mediator_implementation:s cCsd}d}}t|trd|krF|jdd\}}n|}|se|dkr| rytj|dWqtjk r}t|}qXn| r|rtj d|rt dfSn|rt t dt fSt t d|fS( sReturns a tuple of (valid, error) indicating whether the provided string is a valid mediator implementation for mediated links. 'valid' is a boolean and 'error' is None or a string containing the error.R Ris5.11s^[a-zA-Z0-9\-]+$s'%(value)s' is not a valid mediator-implementation; only alphanumeric characters and a version dot-sequence following a single '@' are allowed: %(error)ss'%s' is not a valid mediator-implementation; only alphanumeric characters and a version dot-sequence following a single '@' are allowedN(RRRRR R R RRRRRRR(Rtallow_empty_versionRtinametiverR((s2/usr/lib/python2.7/vendor-packages/pkg/mediator.pytvalid_mediator_implementationYs$      cCs*|dkrtdfSttd|fS(sReturns a tuple of (valid, error) indicating whether the provided string is a valid mediator priority for mediated links. 'valid' is a boolean and 'error' is None or a string containing the error.tsitetvendorsJ'%s' is not a valid mediator-priority; valid values are 'site' or 'vendor'(ssitesvendorN(RRRR(R((s2/usr/lib/python2.7/vendor-packages/pkg/mediator.pytvalid_mediator_priorityxs   iRiRc Cstj|dd}tj|dd}t||}|dkrK|S|d}|d}t||}|dkr|dSt|d\}}t|d\}}t||}|dkr|St||}|dkr|dSdS(sCustom mediation sorting routine. Sort is done by priority, version, implementation name, implementation version. iiiii(t_MED_PRIORITIEStgettcmpR( tatbtapriotbpriotrestavertbvertaimpltbimpl((s2/usr/lib/python2.7/vendor-packages/pkg/mediator.pytcmp_mediationss&      cCss||krtSt|\}}t|\}}||ksM|oI| rQtS|dkpr|dkpr||kS(s(Returns a boolean indicating whether two given mediator implementation strings match. This is needed because an unversioned implementation is matches both versioned and unversioned implementations. This function assumes that the values being compared are valid. N(RRRR(R$R%R+R)R,R*((s2/usr/lib/python2.7/vendor-packages/pkg/mediator.pytmediator_impl_matchess ( Rt pkg.versionR R RRRRR R!R-R.(((s2/usr/lib/python2.7/vendor-packages/pkg/mediator.pyts