AlkantarClanX12
Current Path : /lib64/python2.7/lib2to3/fixes/ |
Current File : //lib64/python2.7/lib2to3/fixes/fix_dict.pyc |
� {fc @ 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 d e j 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 sP e Z e Z d Z d � Z d Z e j e � Z d Z e j 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 } | j } | j } | j d � } | j d � } | s^ | rk | d } n | d k s� t t | � � � g | D] } | j � ^ q� } g | D] } | j � ^ q� } | o� | j | | � } | t j | j t � t | d | j �g � | d j � g } t j | j | � } | p?| srd | _ t t | r]d n d � | g � } n | r�t j | j | g | � } n | j | _ | 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 nt specialt argst new( ( s. /usr/lib64/python2.7/lib2to3/fixes/fix_dict.pyt transform7 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� | j d k r t 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� t S| j j | j | � o� | d | k S( NR t func( t parentt Nonet Falset p1t matchR t iter_exemptR t consuming_callst p2( R R R R ( ( s. /usr/lib64/python2.7/lib2to3/fixes/fix_dict.pyR [ s ( t __name__t __module__t Truet BM_compatiblet PATTERNR&