<s> """<STR_LIT>""" <EOL> from . . import patcomp <EOL> from . . import pytree <EOL> from . . pgen2 import token <EOL> from . . import fixer_base <EOL> from . . fixer_util import Name , Call , Comma , String , is_tuple <EOL> parend_expr = patcomp . compile_pattern ( <EOL> """<STR_LIT>""" <EOL> ) <EOL> class FixPrint ( fixer_base . BaseFix ) : <EOL> BM_compatible = True <EOL> PATTERN = """<STR_LIT>""" <EOL> def transform ( self , node , results ) : <EOL> assert results <EOL> bare_print = results . get ( "<STR_LIT>" ) <EOL> if bare_print : <EOL> bare_print . replace ( Call ( Name ( u"<STR_LIT>" ) , [ ] , <EOL> prefix = bare_print . prefix ) ) <EOL> return <EOL> assert node . children [ <NUM_LIT:0> ] == Name ( u"<STR_LIT>" ) <EOL> args = node . children [ <NUM_LIT:1> : ] <EOL> if len ( args ) == <NUM_LIT:1> and parend_expr . match ( args [ <NUM_LIT:0> ] ) : <EOL> return <EOL> sep = end = file = None <EOL> if args and args [ - <NUM_LIT:1> ] == Comma ( ) : <EOL> args = args [ : - <NUM_LIT:1> ] <EOL> end = "<STR_LIT:U+0020>" <EOL> if args and args [ <NUM_LIT:0> ] == pytree . Leaf ( token . RIGHTSHIFT , u"<STR_LIT>" ) : <EOL> assert len ( args ) >= <NUM_LIT:2> <EOL> file = args [ <NUM_LIT:1> ] . clone ( ) <EOL> args = args [ <NUM_LIT:3> : ] <EOL> l_args = [ arg . clone ( ) for arg in args ] <EOL> if l_args : <EOL> l_args [ <NUM_LIT:0> ] . prefix = u"<STR_LIT>" <EOL> if sep is not None or end is not None or file is not None : <EOL> if sep is not None : <EOL> self . add_kwarg ( l_args , u"<STR_LIT>" , String ( repr ( sep ) ) ) <EOL> if end is not None : <EOL> self . add_kwarg ( l_args , u"<STR_LIT:end>" , String ( repr ( end ) ) ) <EOL> if file is not None : <EOL> self . add_kwarg ( l_args , u"<STR_LIT:file>" , file ) <EOL> n_stmt = Call ( Name ( u"<STR_LIT>" ) , l_args ) <EOL> n_stmt . prefix = node . prefix <EOL> return n_stmt <EOL> def add_kwarg ( self , l_nodes , s_kwd , n_expr ) : <EOL> n_expr . prefix = u"<STR_LIT>" <EOL> n_argument = pytree . Node ( self . syms . argument , <EOL> ( Name ( s_kwd ) , <EOL> pytree . Leaf ( token . EQUAL , u"<STR_LIT:=>" ) , <EOL> n_expr ) ) <EOL> if l_nodes : <EOL> l_nodes . append ( Comma ( ) ) <EOL> n_argument . prefix = u"<STR_LIT:U+0020>" <EOL> l_nodes . append ( n_argument ) </s>
