Nc@suddkZddkiZdZdZdZedZdZhdd6d d 6Z d Z d Z dS( iNcCsFt|to"tid|o 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.6/vendor-packages/pkg/mediator.pytvalid_mediators  cCsd}t|toIyti|dtdfSWq_tij o}t|}q_Xn|ott 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.6/vendor-packages/pkg/mediator.pytvalid_mediator_version(s  c Cst|tpdSd|jo=y|idd\}}Wqkttfj odSXn |}d}|o4yti|d}Wqtij odSXn||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.6/vendor-packages/pkg/mediator.pytparse_mediator_implementation:s   cCsd}d}}t|tod|jo|idd\}}n|}|p|djoG| o?yti|dWqtij o}t|}qXn| o%|oti d|o t dfSn|ot 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.6/vendor-packages/pkg/mediator.pytvalid_mediator_implementationYs$  "   cCs,|djo tdfSttd|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.6/vendor-packages/pkg/mediator.pytvalid_mediator_priorityxs   iRiRc Csti|dd}ti|dd}t||}|djo|S|d}|d}t||}|djo |dSt|d\}}t|d\}}t||}|djo|St||}|djo |dSdS(sCustom mediation sorting routine. Sort is done by priority, version, implementation name, implementation version. iiiii(t_MED_PRIORITIEStgettcmpR( tatbtapriotbpriotrestavertbvertaimpltbimpl((s2/usr/lib/python2.6/vendor-packages/pkg/mediator.pytcmp_mediationss&        cCs{||jotSt|\}}t|\}}||jp|o| otS|djp|djp ||jS(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.6/vendor-packages/pkg/mediator.pytmediator_impl_matchess ( Rt pkg.versionR R RRRRR R!R-R.(((s2/usr/lib/python2.6/vendor-packages/pkg/mediator.pyts