ó
î%![c           @   s°   d  Z  d d l Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d Z d	 e j	 f d
     YZ
 d d  Z d   Z e j e j e e  d S(   s9   Astroid hooks for understanding functools library module.iĸĸĸĸN(   t   BoundMethod(   t   extract_node(   t   helpers(   t   objectmodel(   t   MANAGERs   functools.lru_cachet   LruWrappedModelc           B   s;   e  Z d  Z e d    Z e d    Z e d    Z RS(   sē   Special attribute model for functions decorated with functools.lru_cache.

    The said decorators patches at decoration time some functions onto
    the decorated function.
    c         C   s   |  j  S(   N(   t	   _instance(   t   self(    (    s<   lib/python2.7/site-packages/astroid/brain/brain_functools.pyt   py__wrapped__   s    c            sA   t  d    d t f   f d     Y} | d |  j d |  j  S(   NsQ   
        from functools import _CacheInfo
        _CacheInfo(0, 0, 0, 0)
        t   CacheInfoBoundMethodc              s   e  Z d   f d   Z RS(   c         3   s   t  j    Vd  S(   N(   R   t
   safe_infer(   R   t   callert   context(   t
   cache_info(    s<   lib/python2.7/site-packages/astroid/brain/brain_functools.pyt   infer_call_result"   s    N(   t   __name__t
   __module__t   NoneR   (    (   R   (    s<   lib/python2.7/site-packages/astroid/brain/brain_functools.pyR	   !   s   t   proxyt   bound(   R   R    R   (   R   R	   (    (   R   s<   lib/python2.7/site-packages/astroid/brain/brain_functools.pyt   pycache_info   s    	c         C   s+   t  d  } t d | d |  j j j    S(   Ns   def cache_clear(self): passR   R   (   R   R    R   t   parentt   scope(   R   t   node(    (    s<   lib/python2.7/site-packages/astroid/brain/brain_functools.pyt   pycache_clear'   s    (   R   R   t   __doc__t   propertyR   R   R   (    (    (    s<   lib/python2.7/site-packages/astroid/brain/brain_functools.pyR      s   c         C   s   t    |   |  _ d  S(   N(   R   t   special_attributes(   R   R   (    (    s<   lib/python2.7/site-packages/astroid/brain/brain_functools.pyt   _transform_lru_cache-   s    c         C   s   |  j  s t Sx |  j  j D]s } t | t j  s8 q n  t j | j  } | d t j
 f k re q n  t | t j  r | j   t k r t Sq Wt S(   s=   Check if the given function node is decorated with lru_cache.N(   t
   decoratorst   Falset   nodest
   isinstancet   astroidt   CallR   R
   t   funcR   t   Uninferablet   FunctionDeft   qnamet	   LRU_CACHEt   True(   R   t	   decoratorR#   (    (    s<   lib/python2.7/site-packages/astroid/brain/brain_functools.pyt   _looks_like_lru_cache8   s    	$(   R   R!   R    R   R   t   astroid.interpreterR   R   R'   t   FunctionModelR   R   R   R*   t   register_transformR%   (    (    (    s<   lib/python2.7/site-packages/astroid/brain/brain_functools.pyt   <module>   s   	