관리-도구
편집 파일: fix_dict.cpython-35.opt-1.pyc
��Yf� � @ 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 sn | d } | d d } | d } | j } | j } | j d � } | j d � } | s^ | rn | d d � } 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 | r*d n d � | g � } | r^t j | j | g | � } | j | _ | S)N�head�method� �tailr Zview� c 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) �syms�value� startswith�in_special_contextr ZNodeZtrailerr r r r Zpowerr ) �self�node�resultsr r r r Zmethod_name�isiterZisviewZspecial�args�newr r r � transform7 s2 $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"