o Qi@s$ddlmZddlmZzeWn eyddZYnwzddlmZWn GdddeZYzddl m Z Wn e yHd d Z YnwGd d d e Z d e _Gdd d e ZzeefZWn eymeZYnwddZeefZGdddeZdddZdddZGddde ZdS))ref)BoundMethodWeakrefcCs t|dS)N__call__)hasattr)objectr4/usr/lib/python3/dist-packages/blinker/_utilities.pycallable s r ) defaultdictc@sNeZdZdddZddZddZdd Zd d Zd d ZddZ ddZ dS)r NcOs<|dur t|ds tdtj|g|Ri|||_dS)Nrzfirst argument must be callable)r TypeErrordict__init__default_factory)selfrakwrrrr s  zdefaultdict.__init__cCs,zt||WSty||YSwN)r __getitem__KeyError __missing__)rkeyrrrrs  zdefaultdict.__getitem__cCs&|jdur t||||<}|Sr)rr)rrvaluerrrrs zdefaultdict.__missing__cCs0|jdur t}n|jf}t||dd|fSr)rtupletypeitems)rargsrrr __reduce__%s zdefaultdict.__reduce__cCs|Sr)__copy__rrrrcopy,zdefaultdict.copycCst||j|Sr)rrrrrrr/szdefaultdict.__copy__cCs"ddl}t||j||S)Nr)rrrdeepcopyr)rmemorrrr __deepcopy__2s  zdefaultdict.__deepcopy__cCsd|jt|fS)Nzdefaultdict(%s, %s))rr __repr__rrrrr$7szdefaultdict.__repr__r) __name__ __module__ __qualname__r rrrrrr#r$rrrrr s  r )contextmanagercCsdd}|j|_|S)Nc_std)Nz8Python 2.5 or above is required to use context managers.) RuntimeError)rrrrroops@r zcontextmanager..oops)r%)fnr*rrrr(?sr(c@s$eZdZddZddZddZdS)_symbolcCs||_|_dS)zConstruct a new named symbol.N)r%name)rr-rrrr Hsz_symbol.__init__cCs t|jffSr)symbolr-rrrrrLs z_symbol.__reduce__cCs|jSr)r-rrrrr$Osz_symbol.__repr__N)r%r&r'r rr$rrrrr,Fs r,r.c@seZdZdZiZddZdS)r.a?A constant symbol. >>> symbol('foo') is symbol('foo') True >>> symbol('foo') 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. cCs2z|j|WSty|j|t|YSwr)symbolsr setdefaultr,)clsr-rrr__new__ds   zsymbol.__new__N)r%r&r'__doc__r/r2rrrrr.Ts cCsRt|drt|jt|jfSt|drt|jt|jfSt|tr%|St|S)N__func__im_func)ridr4__self__r5im_self isinstancetext)objrrrhashable_identityqs   r<c@seZdZdZdS)annotatable_weakrefz7A weakref.ref that supports custom instance attributes.N)r%r&r'r3rrrrr=sr=NcKs@t|r t||}nt||}|D] \}}t|||q|S)zReturn an annotated weak ref.)r callable_referencer=rsetattr)rcallback annotationsweakrrrrr references   rCcCsJt|dr|jdurt||dSt|dr |jdur t||dSt||S)z@Return an annotated weak ref, supporting bound instance methods.r8N)target on_deleter7)rr8rr7r=)rr@rrrr>s    r>c@s eZdZdZddZddZdS) lazy_propertyz(A @property that is only evaluated once.cCs||_|j|_dSr) _deferredr3)rdeferredrrrr s zlazy_property.__init__cCs*|dur|S||}t||jj||Sr)rGr?r%)rr;r1rrrr__get__s  zlazy_property.__get__N)r%r&r'r3r rIrrrrrFs rFr)weakrefrblinker._saferefrr NameError collectionsr r contextlibr( ImportErrorrr,r%r.strunicoder:r< WeakTypesr=rCr>rFrrrrs<   ,