ok
Direktori : /opt/alt/python35/lib64/python3.5/lib2to3/fixes/__pycache__/ |
Current File : //opt/alt/python35/lib64/python3.5/lib2to3/fixes/__pycache__/fix_dict.cpython-35.pyc |
K�Ma� � @ 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 d h BZ Gd d � d e j � Z d S)aj 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). � )�pytree)�patcomp)�token)� fixer_base)�Name�Call�LParen�RParen�ArgList�Dot)� fixer_util�iterc @ s^ e 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) �FixDictTa 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^ | rn | d d � } | 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*| sZd | _ t t | rHd n d � | g � } | r|t j | j | g | � } | j | _ | S)N�head�method� �tailr Zview� �keys�items�valuesc S s g | ] } | j � � q S� )�clone)�.0�nr r �;/opt/alt/python35/lib64/python3.5/lib2to3/fixes/fix_dict.py� <listcomp>B s z%FixDict.transform.<locals>.<listcomp>c S s g | ] } | j � � q Sr )r )r r r r r r C s �prefixZparens� �list)r r r )�syms�value� startswith�AssertionError�repr�in_special_contextr ZNodeZtrailerr r r r Zpowerr ) �self�node�resultsr r r r Zmethod_name�isiterZisviewZspecial�args�newr r r � transform7 s4 $zFixDict.transformz3power< func=NAME trailer< '(' node=any ')' > any* >zmfor_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 S| s� d S| j j | j | � o� | d | k S)NFr'