<s> """<STR_LIT>""" <EOL> import prettytable <EOL> from . base import ListFormatter , SingleFormatter <EOL> class TableFormatter ( ListFormatter , SingleFormatter ) : <EOL> ALIGNMENTS = { <EOL> int : '<STR_LIT:r>' , <EOL> str : '<STR_LIT:l>' , <EOL> float : '<STR_LIT:r>' , <EOL> } <EOL> try : <EOL> ALIGNMENTS [ unicode ] = '<STR_LIT:l>' <EOL> except NameError : <EOL> pass <EOL> def add_argument_group ( self , parser ) : <EOL> group = parser . add_argument_group ( '<STR_LIT>' ) <EOL> group . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = <NUM_LIT:0> , <EOL> type = int , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> def emit_list ( self , column_names , data , stdout , parsed_args ) : <EOL> x = prettytable . PrettyTable ( <EOL> column_names , <EOL> print_empty = False , <EOL> ) <EOL> x . padding_width = <NUM_LIT:1> <EOL> if parsed_args . max_width > <NUM_LIT:0> : <EOL> x . max_width = int ( parsed_args . max_width ) <EOL> data_iter = iter ( data ) <EOL> try : <EOL> first_row = next ( data_iter ) <EOL> except StopIteration : <EOL> pass <EOL> else : <EOL> for value , name in zip ( first_row , column_names ) : <EOL> alignment = self . ALIGNMENTS . get ( type ( value ) , '<STR_LIT:l>' ) <EOL> x . align [ name ] = alignment <EOL> x . add_row ( first_row ) <EOL> for row in data_iter : <EOL> x . add_row ( row ) <EOL> formatted = x . get_string ( fields = column_names ) <EOL> stdout . write ( formatted ) <EOL> stdout . write ( '<STR_LIT:\n>' ) <EOL> return <EOL> def emit_one ( self , column_names , data , stdout , parsed_args ) : <EOL> x = prettytable . PrettyTable ( field_names = ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> print_empty = False ) <EOL> x . padding_width = <NUM_LIT:1> <EOL> if parsed_args . max_width > <NUM_LIT:0> : <EOL> x . max_width = int ( parsed_args . max_width ) <EOL> x . align [ '<STR_LIT>' ] = '<STR_LIT:l>' <EOL> x . align [ '<STR_LIT>' ] = '<STR_LIT:l>' <EOL> for name , value in zip ( column_names , data ) : <EOL> x . add_row ( ( name , value ) ) <EOL> formatted = x . get_string ( fields = ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> stdout . write ( formatted ) <EOL> stdout . write ( '<STR_LIT:\n>' ) <EOL> return </s>
