ó
ī%![c           @   sV   d  Z  d d l Z d d l Z d d l m Z d   Z d   Z d   Z d   Z d S(   sÆ  Contains logic for retrieving special methods.

This implementation does not rely on the dot attribute access
logic, found in ``.getattr()``. The difference between these two
is that the dunder methods are looked with the type slots
(you can find more about these here
http://lucumr.pocoo.org/2014/8/16/the-python-i-would-like-to-see/)
As such, the lookup for the special methods is actually simpler than
the dot attribute access.
i’’’’N(   t
   exceptionsc            s   |  j  j   g   } t j j   f d   |  j d t  D  } t t j | |   } | s| t j	 d   d |    n  | S(   Nc         3   s$   |  ] } | j  j   g   Vq d  S(   N(   t   localst   get(   t   .0t   ancestor(   t   name(    s@   lib/python2.7/site-packages/astroid/interpreter/dunder_lookup.pys	   <genexpr>   s   t   recurst	   attributet   target(
   R   R   t	   itertoolst   chaint   from_iterablet	   ancestorst   Truet   listR    t   AttributeInferenceError(   t   nodeR   t   attrst   nodest   values(    (   R   s@   lib/python2.7/site-packages/astroid/interpreter/dunder_lookup.pyt   _lookup_in_mro   s    		c         C   s   t  |  t j t j t j t j t j f  r: t |  |  St  |  t j  rY t	 |  |  St  |  t j
  rx t |  |  St j d | d |    d S(   sŪ   Lookup the given special method name in the given *node*

    If the special method was found, then a list of attributes
    will be returned. Otherwise, `astroid.AttributeInferenceError`
    is going to be raised.
    R   R   N(   t
   isinstancet   astroidt   Listt   Tuplet   Constt   Dictt   Sett   _builtin_lookupt   InstanceR   t   ClassDeft   _class_lookupR    R   (   R   R   (    (    s@   lib/python2.7/site-packages/astroid/interpreter/dunder_lookup.pyt   lookup&   s    	c         C   s@   |  j    } | d  k r3 t j d | d |    n  t | |  S(   NR   R   (   t	   metaclasst   NoneR    R   R   (   R   R   R!   (    (    s@   lib/python2.7/site-packages/astroid/interpreter/dunder_lookup.pyR   >   s    	c         C   s:   |  j  j | g   } | s6 t j d | d |    n  | S(   NR   R   (   R   R   R    R   (   R   R   R   (    (    s@   lib/python2.7/site-packages/astroid/interpreter/dunder_lookup.pyR   I   s    	(   t   __doc__R	   R   R    R   R    R   R   (    (    (    s@   lib/python2.7/site-packages/astroid/interpreter/dunder_lookup.pyt   <module>   s   			