Viewing File: /opt/alt/python35/lib/python3.5/site-packages/__pycache__/cached_property.cpython-35.opt-1.pyc
\UV< @ s d Z d Z d Z d Z d d l m Z d d l Z Gd d d e Z Gd d
d
e Z Gd d d e Z e Z
e Z Gd
d d e Z e Z
e Z d S)zDaniel Greenfeldzpydanny@gmail.comz1.3.0ZBSD )timeNc @ s. e Z d Z d Z d d Z d d Z d S)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
c C s t | d | _ | | _ d S)N__doc__)getattrr func)selfr r /cached_property.py__init__ s zcached_property.__init__c C s4 | d k r | S| j | } | j | j j <| S)N)r __dict____name__)r objclsvaluer r r __get__ s zcached_property.__get__N)r
__module____qualname__r r
r r r r r r s r c @ s. e Z d Z d Z d d Z d d Z d S)threaded_cached_propertyz
A cached_property version for use in environments where multiple threads
might concurrently try to access the property.
c C s. t | d | _ | | _ t j | _ d S)Nr )r r r threadingRLocklock)r r r r r r
$ s z!threaded_cached_property.__init__c C st | d k r | S| j } | j j } | j ? y | | SWn+ t k
rh | j | | j | SYn XWd QRXd S)N)r r r r KeyError
setdefault)r r
r obj_dictnamer r r r ) s
z threaded_cached_property.__get__N)r r r r r
r r r r r r s r c @ sa e Z d Z d Z d d d Z d d Z d d Z d d
Z d d Z d
d Z d S)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.
Nc C s; t | r | } d } n d } | | _ | j | d S)N)callablettl
_prepare_func)r r r r r r r
? s z!cached_property_with_ttl.__init__c C s | j | | S)N)r )r r r r r __call__H s
z!cached_property_with_ttl.__call__c C s | d k r | St } | j } | j } y | | \ } } Wn t k
rS Yn' X| j om | j | | k } | sz | S| j | } | | f | | <| S)N)r r r r r r ) r r
r Znowr r r Zlast_updatedZttl_expiredr r r r L s
z cached_property_with_ttl.__get__c C s | j j | j d d S)N)r popr )r r
r r r
__delete__` s z#cached_property_with_ttl.__delete__c C s | t f | j | j <d S)N)r r r )r r
r r r r __set__c s z cached_property_with_ttl.__set__c C s7 | | _ | r3 | j | _ | j | _ | j | _ d S)N)r r r r )r r r r r r f s
z&cached_property_with_ttl._prepare_func)
r r r r r
r r r! r"