\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 �obj�cls�valuer 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 � threading�RLock�lock)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_dict�namer 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)�callable�ttl� _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'