<s> """<STR_LIT>""" <EOL> from lib2to3 import fixer_base <EOL> from lib2to3 . fixer_util import Call , Name , String , touch_import <EOL> def invocation ( s ) : <EOL> def dec ( f ) : <EOL> f . invocation = s <EOL> return f <EOL> return dec <EOL> class FixOperator ( fixer_base . BaseFix ) : <EOL> BM_compatible = True <EOL> order = "<STR_LIT>" <EOL> methods = """<STR_LIT>""" <EOL> obj = "<STR_LIT>" <EOL> PATTERN = """<STR_LIT>""" % dict ( methods = methods , obj = obj ) <EOL> def transform ( self , node , results ) : <EOL> method = self . _check_method ( node , results ) <EOL> if method is not None : <EOL> return method ( node , results ) <EOL> @ invocation ( "<STR_LIT>" ) <EOL> def _sequenceIncludes ( self , node , results ) : <EOL> return self . _handle_rename ( node , results , u"<STR_LIT>" ) <EOL> @ invocation ( "<STR_LIT>" ) <EOL> def _isCallable ( self , node , results ) : <EOL> obj = results [ "<STR_LIT>" ] <EOL> args = [ obj . clone ( ) , String ( u"<STR_LIT:U+002CU+0020>" ) , String ( u"<STR_LIT>" ) ] <EOL> return Call ( Name ( u"<STR_LIT>" ) , args , prefix = node . prefix ) <EOL> @ invocation ( "<STR_LIT>" ) <EOL> def _repeat ( self , node , results ) : <EOL> return self . _handle_rename ( node , results , u"<STR_LIT>" ) <EOL> @ invocation ( "<STR_LIT>" ) <EOL> def _irepeat ( self , node , results ) : <EOL> return self . _handle_rename ( node , results , u"<STR_LIT>" ) <EOL> @ invocation ( "<STR_LIT>" ) <EOL> def _isSequenceType ( self , node , results ) : <EOL> return self . _handle_type2abc ( node , results , u"<STR_LIT>" , u"<STR_LIT>" ) <EOL> @ invocation ( "<STR_LIT>" ) <EOL> def _isMappingType ( self , node , results ) : <EOL> return self . _handle_type2abc ( node , results , u"<STR_LIT>" , u"<STR_LIT>" ) <EOL> @ invocation ( "<STR_LIT>" ) <EOL> def _isNumberType ( self , node , results ) : <EOL> return self . _handle_type2abc ( node , results , u"<STR_LIT>" , u"<STR_LIT>" ) <EOL> def _handle_rename ( self , node , results , name ) : <EOL> method = results [ "<STR_LIT>" ] [ <NUM_LIT:0> ] <EOL> method . value = name <EOL> method . changed ( ) <EOL> def _handle_type2abc ( self , node , results , module , abc ) : <EOL> touch_import ( None , module , node ) <EOL> obj = results [ "<STR_LIT>" ] <EOL> args = [ obj . clone ( ) , String ( u"<STR_LIT:U+002CU+0020>" + u"<STR_LIT:.>" . join ( [ module , abc ] ) ) ] <EOL> return Call ( Name ( u"<STR_LIT>" ) , args , prefix = node . prefix ) <EOL> def _check_method ( self , node , results ) : <EOL> method = getattr ( self , "<STR_LIT:_>" + results [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . value . encode ( "<STR_LIT:ascii>" ) ) <EOL> if callable ( method ) : <EOL> if "<STR_LIT>" in results : <EOL> return method <EOL> else : <EOL> sub = ( unicode ( results [ "<STR_LIT>" ] ) , ) <EOL> invocation_str = unicode ( method . invocation ) % sub <EOL> self . warning ( node , u"<STR_LIT>" % invocation_str ) <EOL> return None </s>
