Current Path : /usr/lib/python2.7/lib2to3/fixes/ |
Current File : //usr/lib/python2.7/lib2to3/fixes/fix_filter.pyc |
ó —|_c @ se d Z d d l m Z d d l m Z d d l m Z m Z m Z m Z d e j f d „ ƒ YZ d S( s¸ Fixer that changes filter(F, X) into list(filter(F, X)). We avoid the transformation if the filter() call is directly contained in iter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or for V in <>:. NOTE: This is still not correct if the original code was depending on filter(F, X) to return a string if X is a string and a tuple if X is a tuple. That would require type inference, which we don't do. Let Python 2.6 figure it out. i ( t token( t fixer_base( t Namet Callt ListCompt in_special_contextt FixFilterc B s# e Z e Z d Z d Z d „ Z RS( sð filter_lambda=power< 'filter' trailer< '(' arglist< lambdef< 'lambda' (fp=NAME | vfpdef< '(' fp=NAME ')'> ) ':' xp=any > ',' it=any > ')' > > | power< 'filter' trailer< '(' arglist< none='None' ',' seq=any > ')' > > | power< 'filter' args=trailer< '(' [any] ')' > > s future_builtins.filterc C s | j | ƒ r d Sd | k rs t | j d ƒ j ƒ | j d ƒ j ƒ | j d ƒ j ƒ | j d ƒ j ƒ ƒ } n} d | k r³ t t d ƒ t d ƒ | d j ƒ t d ƒ ƒ } n= t | ƒ rà d S| j ƒ } d | _ t t d ƒ | g ƒ } | j | _ | S( Nt filter_lambdat fpt itt xpt noneu _ft sequ u list( t should_skipR t gett cloneR R t Nonet prefixR ( t selft nodet resultst new( ( s. /usr/lib/python2.7/lib2to3/fixes/fix_filter.pyt transform5 s&