Ñò
$8Zc        	   @   s·   d  Z  d d k l Z d d k l Z d d k l Z d d k l Z d d k l Z l	 Z	 l
 Z
 l Z l Z l Z d d k l Z e i e d g ƒ BZ d	 e i f d
 „  ƒ  YZ d S(   sj  Fixer for dict methods.

d.keys() -> list(d.keys())
d.items() -> list(d.items())
d.values() -> list(d.values())

d.iterkeys() -> iter(d.keys())
d.iteritems() -> iter(d.items())
d.itervalues() -> iter(d.values())

d.viewkeys() -> d.keys()
d.viewitems() -> d.items()
d.viewvalues() -> d.values()

Except in certain very specific contexts: the iter() can be dropped
when the context is list(), sorted(), iter() or for...in; the list()
can be dropped when the context is list() or sorted() (but not iter()
or for...in!). Special contexts that apply to both: list(), sorted(), tuple()
set(), any(), all(), sum().

Note: iter(d.keys()) could be written as iter(d) but since the
original d.iterkeys() was also redundant we don't fix this.  And there
are (rare) contexts where it makes a difference (e.g. when passing it
as an argument to a function that introspects the argument).
i   (   t   pytree(   t   patcomp(   t   token(   t
   fixer_base(   t   Namet   Callt   LParent   RParent   ArgListt   Dot(   t
   fixer_utilt   itert   FixDictc           B   sJ   e  Z d  Z d „  Z d Z e i e ƒ Z d Z e i e ƒ Z	 d „  Z
 RS(   s  
    power< head=any+
         trailer< '.' method=('keys'|'items'|'values'|
                              'iterkeys'|'iteritems'|'itervalues'|
                              'viewkeys'|'viewitems'|'viewvalues') >
         parens=trailer< '(' ')' >
         tail=any*
    >
    c         C   sÁ  | d } | d d } | d } |  i  } | i } | i d ƒ } | i d ƒ }	 | p |	 o | d } n | d j p t t | ƒ ‚ g  }
 | D] } |
 | i ƒ  q– ~
 } g  } | D] } | | i ƒ  q½ ~ } | o |  i | | ƒ } | t i | i	 t
 ƒ  t | d | i ƒg ƒ | d i ƒ  g } t i | i | ƒ } | p |	 p3 d | _ t t | o d n d ƒ | g ƒ } n | o  t i | i | g | ƒ } n | i | _ | S(   Nt   headt   methodi    t   tailu   iteru   viewi   u   keysu   itemsu   valuest   prefixt   parensu    u   list(   u   keysu   itemsu   values(   t   symst   valuet
   startswitht   AssertionErrort   reprt   clonet   in_special_contextR    t   Nodet   trailerR	   R   R   t   powerR   (   t   selft   nodet   resultsR   R   R   R   t   method_namet   isitert   isviewt   _[1]t   nt   _[2]t   specialt   argst   new(    (    s,   /usr/lib/python2.6/lib2to3/fixes/fix_dict.pyt	   transform5   s4    

		''		* s3   power< func=NAME trailer< '(' node=any ')' > any* >sm   for_stmt< 'for' any 'in' node=any ':' any* >
            | comp_for< 'for' any 'in' node=any any* >
         c         C   s¿   | i  d  j o t Sh  } | i  i  d  j	 o^ |  i i | i  i  | ƒ oB | d | j o1 | o | d i t j S| d i t i j Sn | p t S|  i	 i | i  | ƒ o | d | j S(   NR   t   func(
   t   parentt   Nonet   Falset   p1t   matchR   t   iter_exemptR
   t   consuming_callst   p2(   R   R   R    R   (    (    s,   /usr/lib/python2.6/lib2to3/fixes/fix_dict.pyR   Y   s    (   t   __name__t
   __module__t   PATTERNR(   t   P1R   t   compile_patternR-   t   P2R1   R   (    (    (    s,   /usr/lib/python2.6/lib2to3/fixes/fix_dict.pyR   *   s   		N(   t   __doc__t    R    R   t   pgen2R   R   R
   R   R   R   R   R   R	   R0   t   setR/   t   BaseFixR   (    (    (    s,   /usr/lib/python2.6/lib2to3/fixes/fix_dict.pyt   <module>   s   .