Hc@sdddddddddd d d d d dddddddddddddddgZddklZlZlZlZlZlZddkl Z l Z l Z l Z l Z lZlZlZdd klZdd!kZdd!kZdd!kZdd!kZyeZeZWnIej o=dd"klZdd#klZd$efd%YZnXy eZWnej od!d&ZnXeZei i!Z"ed]d!d!d'Z#ed!d^d_d!d(Z$d)Z%d*Z&d+Z'ege(d,Z)d-Z*d.Z+d/Z,d0Z-d1Z.d2Z/de0fd3YZ1e1i2dd4Z3d e4fd5YZ5d e5fd6YZ6d e5fd7YZ7de0fd8YZ8d9Z9d!d:Z:defd;YZ;de0fd<YZ<d=e<fd>YZ=d?Z>d@Z?dAZ@dBZAdCZBdDZCdEZDe3eDe)eEe)eEfdFZFddGkGlHZHlIZIe3eDeJeJfeKe3eDeHeHfeKe3eDeJeHfeKe3eDeJe)fdHe3eDe)e)fdIe3eDe)eJfdJe3eDeHeJfdKZLe;eDiMiNe3eBe1e1fdLZOde1fdMYZPePi2dZQe.ePe1d e1fdNYZRe/eRe:dOZSeQeSe0e0fdPZTe3eDeUeUfdQe3eDeUe0fdRe3eDe0eUfdSdeRfdTYZVeVi2dZWe/eVdeRfdUYZXeXi2dZYe/eXe.ePeVe.eVeXe.eXe1e/e5e3eBe1e6fe,e3eBe6e1fe-e;eBiMiNe3eBe7e1fdVZZe3eBe1e7fdWZ[e/e7e3e&e=e\fdXZ]e3e9eJeXidYe:dZZ^e3e^eUfei_e3e^e)fd[d\Z`d!S(`tRuletRuleSett DispatchingtEnginet rules_fortMethodtAroundtBeforetAftert MethodListt DispatchErrortAmbiguousMethodstNoApplicableMethodstabstracttwhentbeforetaftertaroundtistypet parse_ruletimpliestdominant_signaturestcombine_actionst overridestalways_overridestmerge_by_defaultt intersectt disjunctstnegatei(tdecorate_assignmenttdecoratetstructt synchronizedt frameinfotdecorate_class(tCodetConsttCalltLocaltGetattrt TryExcepttSuitet with_name(tAddOnN(tSet(t ImmutableSett frozensetcBs&eZdZddZddZRS(s;Kludge to fix the abomination that is ImmutableSet.__init__cCs&ti||}ti|||S(N(R-t__new__t__init__(tclstiterabletself((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR/scCsdS(N((R3R2((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR0sN(t__name__t __module__t__doc__tNoneR/R0(((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR.s cCs}|o1g}|D]}||||fq~}n t|}|i|o$g}|D]}||dq`~S|S(Ni(tlisttsort(tseqtkeyt_[1]tvtdt_[2]((s3/usr/lib/python2.6/site-packages/peak/rules/core.pytsorteds1  $cCs*|djo t}n||||fS(N(R7t next_sequence(tbodyt predicatet actiontypetsequence((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR-s  cCs9|djo t}n||t|t||fS(s,Hold information needed to parse a predicateN(R7RAtdict(RBRDt localdictt globaldictRE((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyt ParseContext3s  cCs|tjogS|gS(s3Return a *list* of the logical disjunctions of `ob`(tFalse(tob((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR;s cCsM|dj o$t|tjo|f|}nt|i||i|iS(sCHook for pre-processing predicates, e.g. parsing string expressionsN(R7ttypettupleRRBRDRE(tengineRCtcontextR1((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRAs cCs(ti|i|i|i|i|iS(N(tnewtfunctiont func_codet func_globalst func_namet func_defaultst func_closure(tf((s3/usr/lib/python2.6/site-packages/peak/rules/core.pytclone_functionGscCs ||fS(N((RLtmatch((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRTscCsDt|ttfo|St|tjo|io|iSdS(N(t isinstanceRLt ClassTypeRRY(targ((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyttype_keyWsccsGt|tj odSttt|}d|jo |VndS(N(RLRMtmapR]R7(tsigR;((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyt type_keys]s  cCstS(N(tTrue(ts1ts2((s3/usr/lib/python2.6/site-packages/peak/rules/core.pytYESdscCstS(N(RJ(RbRc((s3/usr/lib/python2.6/site-packages/peak/rules/core.pytNOescCs[t|t|}}tt||fttt||fth}g}xttD]}|i}t|tj p#t |djp|i tj oqdnd||<|d|jo|i ||dfn|d|jo|i |d|fqdqdWx>|D]6\}}||f|jot |i|iqqWdS(sE`a` instances always override `b`s; `b` instances never override `a`siiiN( RRRRdReRRCRLRMtlenRBtappendR(tatbtpairstto_addtruleR_tp1tp2((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRgs&  6  cCstt||ftdS(s3instances of `t` never imply other instances of `t`N(RRRe(tt((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRxscBs|eZdZd dd dZeed ddZdZdZ dZ dZ dZ eed d Z RS( s#A simple method w/optional chainingicCs||_||_||_||_t|_yti|d}Wntj onDX|o;|ddjo*t |dddjo t |_qndS(Nit next_methodtim_self( RBt signaturet precedencettailRJtcan_tailtinspectt getargspect TypeErrortgetattrR7Ra(R3RBRrRsRttargs((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR0s     cCs||||S(N((R1RBRrRs((s3/usr/lib/python2.6/site-packages/peak/rules/core.pytmakescCs2|i|i|i|if}|iit|S(N(RBRrRsRtt __class__R4trepr(R3tdata((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyt__repr__scOs1|io|i|i||S|i||S(N(RuRBRt(R3Rztkw((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyt__call__s cCs(|ip|S|it|i|S(N(Rut tail_withRRt(R3tother((s3/usr/lib/python2.6/site-packages/peak/rules/core.pytoverrides cCs|i|i|i|i|S(N(R|RBRrRs(R3Rt((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRscCst||gS(N(R (R3R((s3/usr/lib/python2.6/site-packages/peak/rules/core.pytmergescsr|djod|i}n|tjo dn |idddfd}t||}||_|S(Ns6Extend a generic function with a method of type ``%s``ics%fd}t|||S(Nc sttit|\}}}}t|||fd}|djot|d|n |d|i|fjoS|S(Ncs it||S(N(taddR(R1(RNtrulestpredRO(s3/usr/lib/python2.6/site-packages/peak/rules/core.pytregister_for_classstclasstframe(RRRNR!RIR"R7tget( Rtnametfunct old_localstkindtmoduletlocals_tglobals_R(RWRtmaker(RNRORs3/usr/lib/python2.6/site-packages/peak/rules/core.pytcallbacks   (R(RWRtdepthRR(R(RWRs3/usr/lib/python2.6/site-packages/peak/rules/core.pyRs((R7R4RR{R*R6(R1RtdocR((Rs3/usr/lib/python2.6/site-packages/peak/rules/core.pytmake_decorators     (N((R4R5R6R7R0Rt classmethodR{RRRRRR(((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR|s       s+Extend a generic function with a new actioncBs eZdZdZdZRS(sA dispatch error has occurredcOs |i|i||fdS(N(R|Rz(R3RzR((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRscCs|iit|iS(N(R|R4R}Rz(R3((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRs(R4R5R6RR(((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR s cBseZdZdZRS(s=No applicable action has been defined for the given argumentscCst||gS(N(R (R3R((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRs(R4R5R6R(((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR scBs2eZdZdZdZdZdZRS(s*More than one choice of action is possiblecGsfti|||g}|_x?|D]7}t|to|i|iq'|i|q'WdS(N(R R0tmethodsRZR textendRg(R3RRztminetm((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR0s cCst|i|gS(N(R R(R3R((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRscCs|S(N((R3R((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRscCs d|iS(NsAmbiguousMethods(%s)(R(R3((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRs(R4R5R6R0RRR(((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR s   cBseZdZeZeZdZd dZ e dZ e dZ e dZ eedZe dZdZe d Ze d ZRS( s1An observable, stably-ordered collection of rulesicCs9g|_h|_g|_|dj o ||_ndS(N(Rt actiondefst listenersR7t__lock__(R3tlock((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR0s     cCsFt|i|}|ii|||i|<|id|dS(Ntadded(R.t _actions_forRRgRt_notify(R3RlR((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRs cCs6|ii|}|ii||id|dS(Ntremoved(RtpopRtremoveR(R3RlR((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR scCs4t|}|i2|ii|id|dS(NR(R.RRtclearR(R3R((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRs  cCs)x"|iD]}|i||q WdS(N(Rtactions_changed(R3RRtlistener((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRs cCsB|i}tg}|iD]}||D] }||q(q~S(N(RtiterR(R3tadR<RlRh((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyt__iter__!s ccsT|\}}}}}|p|i}x(t|D]}t||||Vq2WdS(N(tdefault_actiontypeRR(R3t.1tnaRBRCRDR:Rr((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR%s  cCs8|ii||io|it|tndS(N(RRgRRR.tempty(R3R((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyt subscribe+s cCs|ii|dS(N(RR(R3R((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyt unsubscribe1sN(R4R5R6R tdefault_actionRRtcounterR7R0R RRRRRRRRR(((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRs&        cCsIti|p,t|}|iitt|nt|iS(s5Return the initialized ruleset for a generic function(Rt exists_forRRRRX(RWR>((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR5s  cCs/|djotdSt|iSdS(s!Declare a function to be abstractcSst|iS((Rt as_abstract(RWtnRtold((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyt@sN(R7RRR(R((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR <s  cBsoeZdZdZdZedZdZedZ dZ edZ edZ RS( s5Hold the dispatching attributes of a generic functioncCsG||_|i|_t|i|_d|_|it dS(N( RQt _regen_codet_regenRtget_lockRR7tbackupt create_enginet TypeEngine(R3R((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR0Ls   cCs|iS(N(R(R3((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRTscCsS|idj o-|i|iijo|ii|in|||_|iS(s7Create a new engine of `engine_type`, unsubscribing oldN(RNR7RRR(R3t engine_type((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRWs&cCs6|idjo"|ii|_|i|i_ndS(s<Ensure code regeneration occurs on next call of the functionN(RR7RQRRR(R3((s3/usr/lib/python2.6/site-packages/peak/rules/core.pytrequest_regeneration_sc Cskti|idt}|it|ittttt t|ifdt d|i S(Nt copy_linenotfoldt _regenerate( R#t from_functionRQRatreturn_t call_thruR%R'R$RRJtcode(R3tc((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRes$cCsx|iD]}tdq Wti|idt}|it|it|ii |i djo|i |i_ n|i |_ |iS(Ns(Can't make abstract: rules already existR(RtAssertionErrorR#RRQRaRRR$RRR7RRR(R3tactionR((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRss %cCsU|i}|i|_y|ii|_Wn|i|_nXd|_|SdS(N(RQRRRRNt_generate_codeRR7(R3R((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRs    N( R4R5R6R7RNR0R RRRRRR(((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRIs      cBsZeZdZeZdZedZdZdZ dZ dZ dZ RS(s%Abstract base for dispatching enginescCsr|i|_h|_|i|_|i|_tttdt i |id |_ |ii |dS(Ni( RQtregistryRRRR8tflattentfilterR7RvRwtargnamesR(R3tdisp((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyR0s   +cCs|o|io |iSx!|D]}|i|i|q#Wx!|D]}|i|i|qGW|p|o|indS(N(treset_on_removet _full_resett_remove_methodRCt _add_methodt_changed(R3RRRl((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRs cCst|iidS(s%Some change to the rules has occurredN(RRQR(R3((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRscCs7|ii|i|idt|iidS(s*Regenerate any code, caches, indexes, etc.N((RRRRRRQR(R3((s3/usr/lib/python2.6/site-packages/peak/rules/core.pyRs cCsZ|i}|i|i||i}||jot||||||iiD]-\}}xt|D]}|||}||jo+t||ot|||||s  .:0              R  >  RR?          ;