U \UV<ã@sxdZdZdZdZddlmZddlZGdd„deƒZGd d „d eƒZGd d „d eƒZ e Z e Z Gd d„de ƒZ e Z e ZdS)zDaniel Greenfeldzpydanny@gmail.comz1.3.0ÚBSDé)ÚtimeNc@s eZdZdZdd„Zdd„ZdS)Úcached_propertya A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76 cCst|dƒ|_||_dS©NÚ__doc__)ÚgetattrrÚfunc©Úselfr©r ú@/opt/alt/python38/lib/python3.8/site-packages/cached_property.pyÚ__init__s zcached_property.__init__cCs(|dkr |S| |¡}|j|jj<|S©N)rÚ__dict__Ú__name__)r ÚobjÚclsÚvaluer r r Ú__get__szcached_property.__get__N©rÚ __module__Ú __qualname__rr rr r r r r src@s eZdZdZdd„Zdd„ZdS)Úthreaded_cached_propertyú… A cached_property version for use in environments where multiple threads might concurrently try to access the property. cCs t|dƒ|_||_t ¡|_dSr)rrrÚ threadingÚRLockÚlockr r r r r $s z!threaded_cached_property.__init__c Csz|dkr |S|j}|jj}|jPz||WW5QR£Stk rj| || |¡¡YW5QR£SXW5QRXdSr)rrrrÚKeyErrorÚ setdefault)r rrÚobj_dictÚnamer r r r)sz threaded_cached_property.__get__Nrr r r r rsrc@sBeZdZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dS)Úcached_property_with_ttlz× A property that is only computed once per instance and then replaces itself with an ordinary attribute. Setting the ttl to a number expresses how long the property will last before being timed out. NcCs*t|ƒr|}d}nd}||_| |¡dSr)ÚcallableÚttlÚ _prepare_func)r r#rr r r r ?s z!cached_property_with_ttl.__init__cCs| |¡|Sr)r$r r r r Ú__call__Hs z!cached_property_with_ttl.__call__c Csz|dkr |Stƒ}|j}|j}z||\}}Wntk rBYnX|joV|j||k}|s`|S| |¡}||f||<|Sr)rrrrr#r) r rrÚnowrr rZ last_updatedZ ttl_expiredr r r rLs  z cached_property_with_ttl.__get__cCs|j |jd¡dSr)rÚpopr)r rr r r Ú __delete__`sz#cached_property_with_ttl.__delete__cCs|tƒf|j|j<dSr)rrr)r rrr r r Ú__set__csz cached_property_with_ttl.__set__cCs&||_|r"|j|_|j|_|j|_dSr)rrrrr r r r r$fs z&cached_property_with_ttl._prepare_func)N) rrrrr r%rr(r)r$r r r r r!8s r!cs.eZdZdZd‡fdd„ Z‡fdd„Z‡ZS)Ú!threaded_cached_property_with_ttlrNcstt|ƒ |¡t ¡|_dSr)Úsuperr*r rrr)r r#©Ú __class__r r r xsz*threaded_cached_property_with_ttl.__init__c s0|j tt|ƒ ||¡W5QR£SQRXdSr)rr+r*r)r rrr,r r r|s ÿz)threaded_cached_property_with_ttl.__get__)N)rrrrr rÚ __classcell__r r r,r r*rsr*)Ú __author__Ú __email__Ú __version__Ú __license__rrÚobjectrrr!Zcached_property_ttlZtimed_cached_propertyr*Zthreaded_cached_property_ttlZtimed_threaded_cached_propertyr r r r Ús 6