<s> import prettytable <EOL> class EntityFormatter ( object ) : <EOL> """<STR_LIT>""" <EOL> @ staticmethod <EOL> def _list_objects ( obj_list ) : <EOL> columns = [ ] <EOL> data = ( obj . _get_generic_data ( ) for obj in obj_list ) <EOL> if obj_list : <EOL> columns = obj_list [ <NUM_LIT:0> ] . _get_generic_columns ( ) <EOL> return columns , data <EOL> def _get_generic_data ( self ) : <EOL> return self . _get_formatted_data ( ) <EOL> def _get_generic_columns ( self ) : <EOL> return self . columns <EOL> def _get_formatted_entity ( self ) : <EOL> return self . columns , self . _get_formatted_data ( ) <EOL> def __str__ ( self ) : <EOL> """<STR_LIT>""" <EOL> data = self . _get_formatted_data ( ) <EOL> table = prettytable . PrettyTable ( field_names = ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> print_empty = False ) <EOL> table . padding_width = <NUM_LIT:1> <EOL> table . align [ '<STR_LIT>' ] = '<STR_LIT:l>' <EOL> table . align [ '<STR_LIT>' ] = '<STR_LIT:l>' <EOL> for name , value in zip ( self . columns , data ) : <EOL> table . add_row ( ( name , value ) ) <EOL> return table . get_string ( fields = ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def to_dict ( self ) : <EOL> columns , data = self . _get_formatted_entity ( ) <EOL> return dict ( ( key , value ) for ( key , value ) in zip ( columns , data ) ) </s>
