ó #ßøTc@sÝddlZddlZddlZddlmZddlmZddlmZde fd„ƒYZ ej ede ƒe _ de fd„ƒYZd e fd „ƒYZed d d gƒZdefd„ƒYZdS(iÿÿÿÿN(t namedtuple(t_allow_variant(tEmptyIt _VariantscBsbeZed„Zd„Zd„Zd d„Zd„Zd d„Z d„Z d„Z d„Z RS( cCs<tj|ƒtƒ|_x|D]}||||scCs!||kr|||, ) where key is the explicitly set variant name that matched the caller specific variant name.svariant.skey must start w/ variant.svariant.debug.tfalsesunknown variant %sN(Nsfalse(t startswithtKeyErrorRt __getitem__R(RR ((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyt__getitem_internal[s   cCs|j|ƒdS(Ni(t_Variants__getitem_internal(RR ((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyR#qs(RRt__doc__R%R#(((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyRVs tVariantCombinationTemplatecBsVeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( sQClass for holding a template of variant types and their potential values.cCs t|ƒS(N(R'(R((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyt__copy__scCsVt|tƒrt|ƒ}n!t|tƒs?t|gƒ}ntj|||ƒdS(sSOverrides _Variants.__setitem__ to ensure that all values are sets.N(t isinstancetlistRRR (RR R((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyR s cCs!|j|ƒ}|j o |j S(s0Returns whether self is a subset of variant var.(t differencet type_diffst value_diffs(Rtvartres((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pytissubsetšscCsvtggƒ}x`|D]X}||kr;|jj|ƒqx0||||D]}|jj||fƒqNWqW|S(N(t VCTDifferenceR,tappendR-(RR.R/tktv((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyR+Ÿs  cCs2x+|D]#}||kr||||(tsortedtjoin(RtsR3R4tt((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyt__str__·s0( RRR&R(R R0R+R6R7R8R?(((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyR'‰s     R1R,R-tVariantCombinationscBsãeZdZd„Zed„ƒZed„ƒZed„ƒZd„Zd„Z d„Z d„Z d „Z e d „Zd „Zd „Zd „Zd„Zd„Zd„Zed„Zd„Zd„Zd„Zd„ZRS(sClass for keeping track of which combinations of variant values have and have not been satisfied for a particular action.c Cs%t|tƒst‚tƒ|_tƒ|_g}x„t|ƒD]v}|sxg||D]}||fg^qW}q@ng||D]'}|D]}|||fg^qqƒ}|}q@Wg|D]}t|ƒ^qÁ|_t|jƒ} |rý| |_n | |_t j |ƒ|_ d|_ dS(sCreate an instance of VariantCombinations based on the template provided. The 'vct' parameter is the template from which to build the combinations. The 'satisfied' parameter is a boolean which determines whether the combinations created from the template will be considered satisfied or unsatisfied.N( R)R'tAssertionErrorRt_VariantCombinations__sat_sett!_VariantCombinations__not_sat_setR;t frozensett"_VariantCombinations__combinationsRt_VariantCombinations__templateRt$_VariantCombinations__simpl_template( Rtvctt satisfiedttmpR3R4texisttnew_tmptlR/((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyRÎs$   &' "  cCs|jS(N(RF(R((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyttemplatescCs!|js|jS|jtƒSdS(N(RGRBt!_VariantCombinations__calc_simpletTrue(R((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pytsat_set s cCs!|js|jS|jtƒSdS(N(RGRCROtFalse(R((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyt not_sat_sets cCsXt|jtƒ}tj|jƒ|_tj|jƒ|_|j|_|j|_|S(N(R@RFRPRRBRCRGRE(Rtvc((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyR(s   cCsX|j|jkoW|j|jkoW|j|jkoW|j|jkoW|j|jkS(N(RFRBRCRGRE(Rtother((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyt__eq__ s cCs|j|ƒ S(N(RV(RRU((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyt__ne__'scCs|j o|j S(sSReturns whether self was created with any potential variant values.(RBRC(R((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pytis_empty*scCs0|r|jj|jƒS|jj|jƒSdS(sReturns whether the instances in self are a subset of the instances in vc. 'satisfied' determines whether the instances compared are drawn from the set of satisfied instances or the set of unsatisfied instances.N(RBR0RC(RRTRI((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyR00scCsI|jƒs|jƒrtS|j|ƒ}|r>t|jƒS|jƒ S(sŸReturns whether an action whose variants are vc could satisfy dependencies whose variants are self. 'only_not_sat' determines whether only the unsatisfied set of variants for self is used for comparision. When only_not_sat is True, then intersects returns wether vc would satisfy at least one instance which is currently unsatisfied.(RXRPt intersectiontboolRC(RRTt only_not_satRJ((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyt intersects;s  cCsRt|jƒdkst‚tj|ƒ}|j|jM_|j|jM_|S(sXFind those variant values in self that are also in var, and return them.i(tlenRSRARRBRC(RRTR/((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyRYKs cCsd}d}d}|jƒr7|jƒr7d|dfS|jj|jƒr[|}|}n1|jj|jƒr|}|}n |d|fS|j|j@rÖt|jtƒ}|j|j@|_|j|j8_n|j|jr t|jtƒ}|j|j|_|j|j8_n|j|jrjt|jtƒ}|j|j|_|j|j8_n||krƒ|||fS|||fS(syFind those combinations of variants that are satisfied only in self, in both self and vc, and only in vc.N(RRXRFR0RBR@RRRC(RRTt intersecttonly_bigt only_smalltbigtsmall((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pytseparate_satisfiedTs6      cCs<|j|j@}|stS|j|8_|j|O_tS(s£For all instances in vc, mark those instances as being satisfied. Returns a boolean indicating whether any changes have been made.(RBRCRRRP(RRTR ((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pytmark_as_satisfied~s cCs<|j|j@}|stS|j|8_|j|O_tS(s]For all satisfied instances in vc, mark those instances as being unsatisfied.(RBRRRCRP(RRTR ((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pytmark_as_unsatisfiedŠs cCs"|j|jO_tƒ|_dS(s&Mark all instances as being satisfied.N(RBRCR(R((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pytmark_all_as_satisfied•scCs|j S(s^Returns whether all variant combinations for this package have been satisfied.(RC(R((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyt is_satisfied›scCs_|jj|ƒsRi|_|rR|jj|ƒsOtd|j|fƒ‚qRn||_dS(swStore the provided VariantCombinationTemplate as the template to use when simplifying the combinations.stemplate:%s vct:%sN(RFR0RGRA(RRHtassert_on_different_domains((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pytsimplify¡s cCsxg}xL|jD]A}t|jtƒ}|jj|ƒtƒ|_|j|ƒqW|st|jt j |ƒƒn|S(sÄCreate one VariantCombination object for each possible combination of variants. This is useful when each combination needs to be associated with other information.( RER@RFRRRBR RRCR2R(RRJtcRT((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pytsplit_combinations­s cCst|jtƒS(s€Create a copy of this variant combination, but make sure all the variant combinations are marked as unsatisifed.(R@RFRR(R((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pytunsatisfied_copy¾sc s¹|jsd}n1d}x(|jD]}|t|j|ƒ9}q"W|rU|j}n |j}|t|ƒkrwtƒSt}x5|r´t}x"|jD]‰‡fd†}tƒ}xðtjt |d|ƒ|ƒD]Ð\}}t|ƒ}t|ƒt|jˆƒkr||O}qÓnt|jˆƒ} xD|D]<} x3| D]+\} } | ˆkr_qAn| j | ƒqAWq4W| rŠ||O}qÓnt}|j t |ƒƒqÓW|}q–Wq€W|S(s–Given VariantCombinationTemplate to be simplified against, reduce the instances to the empty set if the instances cover all possible combinations of the template provided. A general approach to simplification is currently deemed to difficult in the face of arbitrary numbers of variant types and arbitrary numbers of variant.iics/g|D]$\}}|ˆkr||f^qS(N((R R3R4(t variant_name(s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyt exclude_nameæstkey( RGR]RBRCRRPRRt itertoolstgroupbyR;RR RD( Rtsatt possibilitiesR3trel_sett keep_goingRnt new_rel_settgtexpectedttuptv_nametv_value((Rms1/usr/lib/python2.7/vendor-packages/pkg/variant.pyt __calc_simpleÄsN               cCs dt|jƒt|jƒfS(NsVC Sat:%s Unsat:%s(R;RBRC(R((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyR8,s(RRR&RtpropertyRNRQRSR(RVRWRXR0RRR\RYRcRdReRfRgRPRiRkRlROR8(((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyR@Ês, 8      *     h(RRpttypest collectionsRt pkg._varcetRtpkg.miscRRRt MethodTypeRt allow_actionRR'R1tobjectR@(((s1/usr/lib/python2.7/vendor-packages/pkg/variant.pyts   .39