관리-도구
편집 파일: fix_dict.cpython-33.pyc
� ��f� c @ s� d 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 m Z m Z m Z m Z m Z d d l m Z e j e d g � BZ Gd d � d e j � Z d S( uj 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 ( u pytree( u patcomp( u token( u fixer_base( u Nameu Callu LParenu RParenu ArgListu Dot( u fixer_utilu iterc B sb | Ee Z d Z d Z d Z d d � Z d Z e j e � Z d Z e j e � Z d d � Z d S( u FixDictu 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 } | j } | j } | j d � } | j d � } | s^ | rq | d d � } n | d k s� t t | � � � d d � | D� } d d � | D� } | o� | j | | � } | t j | j t � t | d | j �g � | d j � g } t j | j | � } | p-| s`d | _ t t | rKd n d � | g � } n | r�t j | j | g | � } n | j | _ | S( Nu headu methodi u tailu iteru viewi u keysu itemsu valuesc S s g | ] } | j � � q S( ( u clone( u .0u n( ( u; /opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_dict.pyu <listcomp>B s u% FixDict.transform.<locals>.<listcomp>c S s g | ] } | j � � q S( ( u clone( u .0u n( ( u; /opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_dict.pyu <listcomp>C s u prefixu parensu u list( u keysu itemsu values( u symsu valueu startswithu AssertionErroru repru in_special_contextu pytreeu Nodeu traileru Dotu Nameu prefixu cloneu poweru Call( u selfu nodeu resultsu headu methodu tailu symsu method_nameu isiteru isviewu specialu argsu new( ( u; /opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_dict.pyu transform7 s4 'u FixDict.transformu3 power< func=NAME trailer< '(' node=any ')' > any* >um for_stmt< 'for' any 'in' node=any ':' any* > | comp_for< 'for' any 'in' node=any any* > c C s� | j d k r d Si } | j j d k r� | j j | j j | � r� | d | k r� | rm | d j t k S| d j t j k Sn | s� d S| j j | j | � o� | d | k S( Nu nodeu funcF( u parentu Noneu Falseu p1u matchu valueu iter_exemptu fixer_utilu consuming_callsu p2( u selfu nodeu isiteru results( ( u; /opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_dict.pyu in_special_context[ s u FixDict.in_special_contextNT( u __name__u __module__u __qualname__u Trueu BM_compatibleu PATTERNu transformu P1u patcompu compile_patternu p1u P2u p2u in_special_context( u __locals__( ( u; /opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_dict.pyu FixDict* s u FixDictN( u __doc__u u pytreeu patcompu pgen2u tokenu fixer_baseu fixer_utilu Nameu Callu LParenu RParenu ArgListu Dotu consuming_callsu setu iter_exemptu BaseFixu FixDict( ( ( u; /opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_dict.pyu <module> s .