<s> class TablePrinter ( object ) : <EOL> "<STR_LIT>" <EOL> def __init__ ( self , fmt , sep = '<STR_LIT:U+0020>' , ul = None ) : <EOL> """<STR_LIT>""" <EOL> super ( TablePrinter , self ) . __init__ ( ) <EOL> self . fmt = str ( sep ) . join ( '<STR_LIT>' . format ( key , width , lb = '<STR_LIT:{>' , rb = '<STR_LIT:}>' ) for heading , key , width in fmt ) <EOL> self . head = { key : heading for heading , key , width in fmt } <EOL> self . ul = { key : str ( ul ) * width for heading , key , width in fmt } if ul else None <EOL> self . width = { key : width for heading , key , width in fmt } <EOL> def row ( self , data ) : <EOL> return self . fmt . format ( ** { k : str ( data . get ( k , '<STR_LIT>' ) ) [ : w ] for k , w in self . width . iteritems ( ) } ) <EOL> def __call__ ( self , dataList ) : <EOL> _r = self . row <EOL> res = [ _r ( data ) for data in dataList ] <EOL> res . insert ( <NUM_LIT:0> , _r ( self . head ) ) <EOL> if self . ul : <EOL> res . insert ( <NUM_LIT:1> , _r ( self . ul ) ) <EOL> return '<STR_LIT:\n>' . join ( res ) </s>
