WOc&@sddkZddkZddkZddkZddkZddkZddkZedZddk l Z yddk Z Wne j oddk Z nXeedep eid^jZeo eZneid_joddkZeeifZnzd deddfZyeiideWnej oddkZnXddkZeiieeeifZeZeoddkZn3yddk ZWne j oddkZnXd Z!eed e!Z!eid`jod e"fdYZ#nd e"fdYZ#eo dZ$n ei$Z$eoddk%l&Z&n ei&Z&yddk'l(Z(Wn)e j ode"fdYZ(nXddZ)dZ*dZ+yddk%l,Z,Wn"e j odadbdZ,nXyddk%l-Z-WndZ-nXdd Z.d!Z/d"Z0eidcjo d#Z1n d$Z1d%Z2d&Z3d'Z4e5d(Z6e5d)Z7d*Z8d+Z9d,Z:d-Z;d.Z<e5d/Z=dd0Z>d1Z?d2Z@d3aAd4ZBd5ZCddd6dd7ZDd8eEfd9YZFd:e"fd;YZGd<efd=YZHd>eEfd?YZId@eIfdAYZJdBZKeZLe"ZMeHZNe#ZOedCZPdDeEfdEYZQdFeEfdGYZRdHeRfdIYZSdJeEfdKYZTdLeT_UdLeEfdMYZVddddNZWdOZXdPeEfdQYZYdReEfdSYZZdTZ[dUei\fdVYZ]dWZ^dXZ_dYZ`de5dZZade5d[Zbdd\Zcd]ZddS(diNttypes(texct py3kwarningiiiitignorecCs|S(N((tx((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytbuffer2sRit PopulateDictcBs eZdZdZdZRS(sA dict which populates missing values via a creation function. Note the creation function takes a key, unlike collections.defaultdict. cCs ||_dS(N(tcreator(tselfR((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyt__init__@scCs|i|||<}|S(N(R(Rtkeytval((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyt __missing__Cs(t__name__t __module__t__doc__R R (((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR8s cBs eZdZdZdZRS(s>A dict which populates missing values via a creation function.cCs ||_dS(N(R(RR((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR JscCsFyti||SWn+tj o|i|||<}|SXdS(N(tdictt __getitem__tKeyErrorR(RR tvalue((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRMs (R RRR R(((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRGs cCs t|dS(Nt__call__(thasattr(tfn((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytcallableUs(treduce(t defaultdictRcBsSeZddZdZdZdZdZdZdZ dZ RS( cOsN|dj o!t|d otdnti|||||_dS(NRsfirst argument must be callable(tNoneRt TypeErrorRR tdefault_factory(RRtatkw((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR cs  cCs8yti||SWntj o|i|SXdS(N(RRRR (RR ((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRiscCs8|idjot|n|i||<}|S(N(RRR(RR R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR nscCsH|idjo t}n |if}t||dd|ifS(N(RRttuplettypet iteritems(Rtargs((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyt __reduce__ss  cCs |iS(N(t__copy__(R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytcopyyscCst||i|S(N(R R(R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR${scCs1ddk}t||i|i|iS(Ni(R%R Rtdeepcopytitems(RtmemoR%((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyt __deepcopy__}s cCsd|iti|fS(Nsdefaultdict(%s, %s)(RRt__repr__(R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR*s N( R RRR RR R#R%R$R)R*(((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRbs       cCs8|djo|St|ttfp|gS|SdS(N(Rt isinstancetlistR(Rtdefault((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytto_lists  cCs>|djotSt|tptt|S|SdS(N(RtsetR+R.(R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytto_sets  cCs>|djotSt|tptt|S|SdS(N(Rt column_setR+R.(R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyt to_column_sets  (tupdate_wrapperRRR t__dict__cCsax'|D]}t||t||qWx0|D](}t||it||dq1W|S(N((tsetattrtgetattrtupdate(twrappertwrappedtassignedtupdatedtattr((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR3s&(tpartialcsfd}|S(Ncs*i}|i|||S(N(R%R7(tfargst fkeywordst newkeywords(R"tfunctkeywords(s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytnewfuncs  ((RAR"RBRC((RBR"RAs3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR=scsfd}|S(NcsCtifdfd}t|S(Ncsrogdjo ti}n ti}ditiddf}ti||ddndS(Ntpendings%s%s now accepts multiple %s arguments as a variable argument list. Supplying %s as a single list is deprecated and support will be removed in a future release.it stackleveli(RtSAPendingDeprecationWarningtSADeprecationWarningt func_nametinspectt formatargspectwarningstwarn(t warning_typetmsg(tlist_deprecationtspecR(s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyt _deprecates    csOt|dto*|t|dd!|d|S|||SdS(Nii(R+R,(RR"R(RQ(s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytgos#(RIt getargspect decorator(RRR(RO(RRQRPs3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytdecorates((RORU((ROs3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytaccepts_a_list_as_starargssc'st|}x|D]{tiftifdtd}xB|D]*}||jo|i||VPqPqPWtdqWdS(Ncst|S((tstr(ti(tbase(s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytsis&exhausted namespace for symbol base %s(R/t itertoolstchaintimaptxrangetaddt NameError(tusedtbasestpooltsym((RYs3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytunique_symbolss     csfd}t|S(s'A signature-matching decorator factory.csti|}t|d|dd!|if}t|dd\}}td|d|}|it|dtd|}t |h|6||6}t |d|i |_ t ||S( NiiittargetRtgroupeds1lambda %(args)s: %(target)s(%(fn)s, %(apply_kw)s)tim_func( RIRSRRHReRR7tformat_argspec_plustFalsetevalR6t func_defaultsR3(RRPtnamest targ_nametfn_nametmetadatatcodet decorated(Rf(s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRUs%(R3(RfRU((Rfs3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRTs cCs`g}xM|i|i|ifD]3}t|do|i}n|i|qWt|S(szdecode a slice object as sent to __getitem__. takes into account the 2.5 __index__() method, basically. t __index__(tstarttstoptstepRRstappendR(tslctretR((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyt decode_slicescCs|i|i|ifS(N(RtRuRv(Rx((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRzsccs[xT|D]L}t|t o0t|do x"t|D] }|Vq;Wq|VqWdS(sGiven an iterator of which further sub-elements may also be iterators, flatten the sub-elements into a single iterator. t__iter__N(R+t basestringRtflatten_iterator(Rtelemty((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR} s!  c Csx9|iD]*}d|ijot|g}Pq q WgSt}x|o|i}|iidt}| pt|ti oqHnt i |\}}}}|i ||o|i |i qHqHW|i dt|S(smReturn the full set of inherited kwargs for the given `cls`. Probes a class's __init__ method, collecting all named arguments. If the __init__ defines a \**kwargs catch-all, then the constructor is presumed to pass along unrecognized keywords to it's base classes, and the collection process is repeated recursively on each of the bases. R R(t__mro__R4R/tpoptgetRjR+Rt FunctionTypeRIRSR7t __bases__tdiscardR,( tclstctstackR"tclass_tctrRmt_thas_kw((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytget_cls_kwargss&      cCsti|dS(s9Return the full set of legal kwargs for the given `func`.i(RIRS(RA((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytget_func_kwargs3scCsSt|oti|p|}ti|}|do|dd}n$|dod|d}nd }ti|d|d|d}|dd j o|ddt|dpd}ti|d|d|d|dd}|o td|d |d |d |Std|dd !d |d |dd !d |dd !Sd S(sReturns a dictionary of formatted, introspected function arguments. A enhanced variant of inspect.formatargspec to support code generation. fn An inspectable callable or tuple of inspect getargspec() results. grouped Defaults to True; include (parens, around, argument) lists Returns: args Full inspect.formatargspec for fn self_arg The name of the first positional argument, varargs[0], or None if the function defines no positional arguments. apply_pos args, re-written in calling rather than receiving syntax. Arguments are passed positionally. apply_kw Like apply_pos, except keyword-ish args are passed as keywords. Example:: >>> format_argspec_plus(lambda self, a, b, c=3, **d: 123) {'args': '(self, a, b, c=3, **d)', 'self_arg': 'self', 'apply_kw': '(self, a, b, c=c, **d)', 'apply_pos': '(self, a, b, c, **d)'} iis%s[0]iit formatvaluecSsd|S(t=((R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRZbsR"tself_argt apply_postapply_kwiN((RRIRSRJRtlenR(RRgRPR"RRtdefaulted_valsR((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRi7s #  !4! c Csyt|d|SWnqtj oed}|tijo|odpd}n|odpd}tddd|d|d |SXd S( s format_argspec_plus with considerations for typical __init__ methods Wraps format_argspec_plus with error handling strategies for typical __init__ cases:: object.__init__ -> (self) other unreflectable (usually C) -> (self, *args, **kwargs) RgRs(self)s(self, *args, **kwargs)sself, *args, **kwargsRR"RRN(RiRtobjectR R(tmethodRgRR"((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytformat_argspec_initjs cCsbyti|SWnJtj o>|tijodgdddfSdgdddfSnXdS(sinspect.getargspec with considerations for typical __init__ methods Wraps inspect.getargspec with error handling for typical __init__ cases:: object.__init__ -> (self) other unreflectable (usually C) -> (self, *args, **kwargs) RR"tkwargsN(RIRSRRR R(R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytgetargspec_inits cCs.t|tio|i o|iS|SdS(sIAdjust the incoming callable such that a 'self' argument is not required.N(R+Rt MethodTypetim_selfRh(t func_or_cls((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytunbound_method_to_callablescs;t|tiotSt|gt|i}x|o|i}t|tioq<nx;fd|iDD] }|i|i |qW|i djpt |d oq<nxZg}|i D]}|jo ||qq~D] }|i|i |qWq<WtS(sReturn an unordered sequence of all classes related to cls. Traverses diamond hierarchies. Fibs slightly: subclasses of builtin types are not returned. Thus class_hierarchy(class A(object)) returns (A, object), not A plus every class systemwide that derives from object. Old-style classes are discarded and hierarchies rooted on them will not be descended. c3s>x7|]0}|jot|ti o |VqqWdS(N(R+Rt ClassType(t.0R(thier(s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pys s t __builtin__t__subclasses__( R+RRR,R/RRRRwR_RRR(RtprocessRtbt_[1]Rts((Rs3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytclass_hierarchys(   !9 ccs\t|}xI|D]A}x8|iD]-}||ijo||i|fVPq#q#WqWdS(siterate all the keys and attributes associated with a class, without using getattr(). Does not use getattr() so that class-sensitive descriptors (i.e. property.__get__()) are not called. N(tdirRR4(RtkeysR R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytiterate_attributess  cCsjt|ttfoJ|ii}|djotS|djotStd |nt|S(NttruetyestonRttt1tfalsetnotofftntft0sString is not true/false: %r(RRRRRR(RRRRRR( R+RWtunicodetstriptlowertTrueRjt ValueErrortbool(tobj((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytasbools  cCs}||jolt|||j oU||dj oD|tjo|ot||||s N(RR!titerR'R6RRR(RR((RRs3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytdictlike_iteritemss  !cCst||o|St|to?tid|did|Dtt|fn/tid|t|tt|fdS(Ns8Argument '%s' is expected to be one of type %s, got '%s's or css#x|]}dt|VqWdS(s'%s'N(RW(RR((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pys s s6Argument '%s' is expected to be of type '%s', got '%s'(R+RRt ArgumentErrortjoinRWR (targtargtypetname((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytassert_arg_types ?icCst|_td7adS(sAssign a '_creation_order' sequence to the given instance. This allows multiple instances to be sorted in order of creation (typically within a single thread; the counter is not particularly threadsafe). iN(t_creation_order(tinstance((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytset_creation_order s cOs:y|||SWn"tdtidd!nXdS(sNexecutes the given function, catches all exceptions and converts to a warning.s%s('%s') ignorediiN(RLtsystexc_info(RAR"R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytwarn_exception,ss self.proxycBs|o |}n|djo d}ng}e|D]O}|ido9|ido)e|| o||jo ||q9q9~}x6|D].} y<e|| } e| dpwne| d | } Wnej o qnXy=ei| } ei | d } ei | d d } Wne j od } d } nXde }|dj oh||6ph}||Uy| i || _ Wnej onXe || || qWdS(s9Automates delegation of __specials__ for a proxying type.t __slots__t__del__t__getattribute__t __metaclass__t __getstate__t __setstate__t__RRhiis(self, *args, **kw)s (*args, **kw)s?def %(method)s%(fn_args)s: return %(name)s.%(method)s%(d_args)sN(s __slots__s__del__s__getattribute__s __metaclass__s __getstate__s __setstate__(RRt startswithtendswithRR6tAttributeErrorRIRSRJRtlocalsRlR5(tinto_clstfrom_clstskiptonlyRt from_instancetdundersRtmRRRPtfn_argstd_argstpytenv((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytmonkeypatch_proxied_specials3sB    2  !tOrderedPropertiescBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZddZdZdZdZRS(sgAn object that maintains the order in which attributes are set upon it. Also provides an iterator and a very basic getitem/setitem interface to those attributes. (Not really a dict, since it iterates over values, not keys. Not really a list, either, since each value must have a key associated; hence there is no append or extend.) cCst|id/s (R/R(RR((Rs3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyt intersection-s csLtifdD}|ifdD|S(Nc3s*x#|]}|jo |VqqWdS(N((RR(R(s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pys 5s c3s*x#|]}|jo |VqqWdS(N((RR(R(s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pys 6s (R/RR7(RRR((RRs3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytsymmetric_difference3s cs)t|ifd|DS(Nc3s*x#|]}|jo |VqqWdS(N((RR(R(s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pys =s (R/R(RR((Rs3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyt difference;s cCsXt|}ti||g}|iD]}||jo ||q*q*~|_|S(N(R/tintersection_updateR(RRRR((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRAs 8cCsti||g}|iD]}||jo ||qq~|_|ig}|iD]}||jo ||q]q]~7_|S(N(R/tsymmetric_difference_updateR(RRRRt_[2]((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRIs8>cCsLti||g}|iD]}||jo ||qq~|_|S(N(R/tdifference_updateR(RRRR((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRQs8N(R RRR R_RR RRRR{R*t__str__R7t__ior__Rt__or__Rt__and__Rt__xor__Rt__sub__Rt__iand__Rt__ixor__Rt__isub__(((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR s4                 t IdentitySetcBsseZdZeZd'dZdZdZdZ dZ dZ dZ dZ d Zd Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$d Z%d!Z&d"Z'e'Z(d#Z)d$Z*d%Z+d&Z,RS((sA set that considers only object id() for uniqueness. This strategy has edge cases for builtin types- it's possible to have two 'foo' strings in one of these sets, for example. Use sparingly. cCs9t|_|o"x|D]}|i|qWndS(N(Rt_membersR_(RRto((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR cs  cCs||it|s (R#R(R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR3scCs"t|tptS|i|S(N(R+R"R,R(RR((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRscCs|i|i|_dS(N(RR#(RR((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRscCs&t|tptS|i||S(N(R+R"R,R(RR((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR  s cCst||iiS(N(R R#R(R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR%scCs t|iS(N(RR#(R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRscCs |iiS(N(R#R(R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR{scCstddS(Nsset objects are unhashable(R(R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyt__hash__scCs dt|i|iifS(Ns%s(%r)(R R R#R(R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR*sN(-R RRR/R2RR R_RRRRRR'R(R)R+R-R.R/R0R1RRR7RRRRR!RRRRRR3RRR R%R$RR{R6R*(((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR"YsR                                   tOrderedIdentitySetcBs*eZdefdYZddZRS(R2cBseZeZRS((R RRt__sa_hash_exempt__(((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR2$scCsFti|t|_|o"x|D]}|i|q'WndS(N(R"R RR#R_(RRR$((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR +s   N(R RR R2RR (((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR7#sccs&x|D]}t||fVqWdS(s*Generator: ((id(o), o) for o in iterable).N(R%(RR((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR42scCsJ|}g}|D]/}||jo|i| o ||qq~S(N(R_(tseqt compare_withtseenRR((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyt unique_list?s tUniqueAppendercBs,eZdZddZdZdZRS(sAppends items to a collection ensuring uniqueness. Additional appends() of the same object are ignored. Membership is determined by identity (``is a``) not equality (``==``). cCsv||_t|_|ot|||_nAt|do|i|_n!t|do|i|_ndS(NRwR_(tdataR"t_uniqueR6t_data_appenderRRwR_(RR>tvia((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR Js  cCs5||ijo!|i||ii|ndS(N(R?R@R_(RR((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRwUs cCs t|iS(N(RR>(R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR{ZsN(R RRRR RwR{(((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR=Cs tScopedRegistrycBsGeZdZddZdZdZdZdZdZ RS(sxA Registry that can store one or multiple instances of a single class on a per-thread scoped basis, or on a customized scope. createfunc a callable that returns a new object to be placed in the registry scopefunc a callable that will return a key to store/retrieve an object. If None, ScopedRegistry uses a threading.local object instead. cCs&|ptitSti|SdS(N(Rt__new__t_TLocalRegistry(Rt createfunct scopefunc((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRCjscCs||_||_h|_dS(N(RERFtregistry(RRERF((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR ps  cCsK|i}y|i|SWn)tj o|ii||iSXdS(N(RFRGRRRE(RR ((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRus  cCs|i|ijS(N(RFRG(R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pythas|scCs||i|i(R(R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR*s(R RR R#R*(((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRKs  RLcBs)eZdZhZeiZdZRS(sIA constant symbol. >>> symbol('foo') is symbol('foo') True >>> symbol('foo') A slight refinement of the MAGICCOOKIE=object() pattern. The primary advantage of symbol() is its repr(). They are also singletons. Repeated calls of symbol('name') will all return the same instance. cCsd|iizB|ii|}|djot||i|<}n|SWdtiiXdS(N(t_locktacquiretsymbolsRRRKRLtrelease(RRRd((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRCs  (R RRRORItLockRMRC(((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRLs  c CsW| o| otdnt|tot||o|St|p9g}t|D]!}|idp ||q`q`~}tt|}ti}t|to |}n*|pt}ti}n t|}||i ||o|St|t j oC|tijodpd} td|| di |fndt fdY} |od |i | _ nt} xt|D]w\} } | |jotd | nt| ptd | | fnt| | t| | i| qW|| |o| Std di || d S(sEnsure basic interface compliance for an instance or dict of callables. Checks that ``obj`` implements public methods of ``cls`` or has members listed in ``methods``. If ``required`` is not supplied, implementing at least one interface method is sufficient. Methods present on ``obj`` that are not in the interface are ignored. If ``obj`` is a dict and ``dict`` does not meet the interface requirements, the keys of the dictionary are inspected. Keys present in ``obj`` that are not in the interface will raise TypeErrors. Raises TypeError if ``obj`` does not meet the interface criteria. In all passing cases, an object with callable members is returned. In the simple case, ``obj`` is returned as-is; if dict processing kicks in then an anonymous class is returned. obj A type, instance, or dictionary of callables. cls Optional, a type. All public methods of cls are considered the interface. An ``obj`` instance of cls will always pass, ignoring ``required``.. methods Optional, a sequence of method names to consider as the interface. required Optional, a sequence of mandatory implementations. If omitted, an ``obj`` that provides at least one interface method is considered sufficient. As a convenience, required may be a type, in which case all public methods of the type are required. s2a class or collection of method names are requiredRsany ofsall ofs%r does not implement %s: %ss, tAnonymousInterfacecBseZdZRS(sA callable-holding shell.(R RR(((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRRst Anonymouss%r: unknown in this interfaces%r=%r is not callables,dictionary does not contain required keys %sN(RR+R R/RRtoperatortgetgtRRRRR RRR5t staticmethodR_(RRtmethodstrequiredRRt interfacet implementedtcompliest qualifierRRtfoundRtimpl((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyt as_interfacesF! H          cCsNy ||_Wn:tj o.ti|i|i||i|i}nX|S(sReturn a function with a given __name__. Will assign to __name__ and return the original function if possible on the Python implementation, otherwise a new function will be constructed. (R RRRt func_codet func_globalsRlt func_closure(RR((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytfunction_nameds  tmemoized_propertycBs#eZdZddZdZRS(s2A read-only @property that is only evaluated once.cCs,||_|p|i|_|i|_dS(N(tfgetRR (RRftdoc((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR )s cCs3|djodS|i||i|i<}|S(N(RRfR4R (RRRR((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyt__get__.s N(R RRRR Rh(((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRe's tmemoized_instancemethodcBs#eZdZddZdZRS(sDecorate a method memoize its return value. Best applied to no-arg methods: memoization is not sensitive to argument values, and will always return the same value even when called with different arguments. cCs,||_|p|i|_|i|_dS(N(RfRR (RRfRg((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR =s cs@djodSfd}i|_i|_|S(NcsPi||fd}i|_i|_|ii<S(NcsS(((RR(R(s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRZGs(RfR RR4(R"RR((RR(Rs3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytoneshotEs   (RR R(RRRRj((RRs3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRhBs    N(R RRRR Rh(((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyRi5s cCs|ii|ddS(N(R4RR(RR((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pytreset_memoizedPstWeakIdentityMappingcBseZdZedZdZdZdZddZ edZ dZ dZ d Z dd Zd eifd YZd ZRS(s)A WeakKeyDictionary with an object identity index. Adds a .by_id dictionary to a regular WeakKeyDictionary. Trades performance during mutation operations for accelerated lookups by id(). The usual cautions about weak dictionaries and iteration also apply to this subclass. tnonecCs&tii|h|_h|_dS(N(tweakreftWeakKeyDictionaryR tby_idt _weakrefs(R((s3/usr/lib/python2.6/site-packages/sqlalchemy/util.pyR _s cCs]t|}||i|<||ijo|i||i|sH  "         $     !      3        (ETd  * Q  T