U
    Ú²gs  ã                   @   s    d dl Z dd„ Zdd„ ZdZdS )é    Nc                  C   s2   zddl m}  d}W n tk
r,   d}Y nX |S )Nr   )Ú_messageTF)Zgoogle._upbr   ÚImportError)r   Úhas_upb© r   ú//tmp/pip-unpacked-wheel-zasgy6sz/proto/utils.pyr      s    
r   c                    s   t  ˆ ¡‡ fdd„ƒ}t|ƒS )zöMake the callable into a cached property.

    Similar to @property, but the function will only be called once per
    object.

    Args:
        fx (Callable[]): The property function.

    Returns:
        Callable[]: The wrapped function.
    c                    s@   t | dƒst | di ¡ ˆ j| jkr4ˆ | ƒ| jˆ j< | jˆ j S )NÚ_cached_values)ÚhasattrÚobjectÚ__setattr__Ú__name__r   )Úself©Úfxr   r   Úinner)   s
    
zcached_property.<locals>.inner)Ú	functoolsÚwrapsÚproperty)r   r   r   r   r   Úcached_property   s    r   )r   )r   r   r   Ú__all__r   r   r   r   Ú<module>   s   
