#NEWLINE# def pformat( self ) : #NEWLINE# #INDENT# column_count = len ( self . _columns ) #NEWLINE# column_sizes = ( [ 0 ] * column_count ) #NEWLINE# headers = [ ] #NEWLINE# for ( i , column ) in enumerate ( self . _columns ) : #NEWLINE# #INDENT# possible_sizes_iter = itertools . chain ( [ len ( column ) ] , ( len ( row [ i ] ) for row in self . _rows ) ) #NEWLINE# column_sizes [ i ] = self . _size_selector ( possible_sizes_iter ) #NEWLINE# headers . append ( self . _center_text ( column , column_sizes [ i ] ) ) #NEWLINE# #UNINDENT# header_footer_buf = six . StringIO ( ) #NEWLINE# header_footer_buf . write ( self . HEADER_FOOTER_JOINING_CHAR ) #NEWLINE# for ( i , header ) in enumerate ( headers ) : #NEWLINE# #INDENT# header_footer_buf . write ( ( self . HEADER_FOOTER_CHAR * len ( header ) ) ) #NEWLINE# if ( ( i + 1 ) != column_count ) : #NEWLINE# #INDENT# header_footer_buf . write ( self . HEADER_FOOTER_JOINING_CHAR ) #NEWLINE# #UNINDENT# #UNINDENT# header_footer_buf . write ( self . HEADER_FOOTER_JOINING_CHAR ) #NEWLINE# content_buf = six . StringIO ( ) #NEWLINE# content_buf . write ( header_footer_buf . getvalue ( ) ) #NEWLINE# content_buf . write ( self . LINE_SEP ) #NEWLINE# content_buf . write ( self . COLUMN_STARTING_CHAR ) #NEWLINE# for ( i , header ) in enumerate ( headers ) : #NEWLINE# #INDENT# if ( ( i + 1 ) == column_count ) : #NEWLINE# #INDENT# if self . COLUMN_ENDING_CHAR : #NEWLINE# #INDENT# content_buf . write ( headers [ i ] ) #NEWLINE# content_buf . write ( self . COLUMN_ENDING_CHAR ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# content_buf . write ( headers [ i ] . rstrip ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# content_buf . write ( headers [ i ] ) #NEWLINE# content_buf . write ( self . COLUMN_SEPARATOR_CHAR ) #NEWLINE# #UNINDENT# #UNINDENT# content_buf . write ( self . LINE_SEP ) #NEWLINE# content_buf . write ( header_footer_buf . getvalue ( ) ) #NEWLINE# row_count = len ( self . _rows ) #NEWLINE# if row_count : #NEWLINE# #INDENT# content_buf . write ( self . LINE_SEP ) #NEWLINE# for ( i , row ) in enumerate ( self . _rows ) : #NEWLINE# #INDENT# pieces = [ ] #NEWLINE# for ( j , column ) in enumerate ( row ) : #NEWLINE# #INDENT# pieces . append ( self . _center_text ( column , column_sizes [ j ] ) ) #NEWLINE# if ( ( j + 1 ) != column_count ) : #NEWLINE# #INDENT# pieces . append ( self . COLUMN_SEPARATOR_CHAR ) #NEWLINE# #UNINDENT# #UNINDENT# blob = '' . join ( pieces ) #NEWLINE# if self . COLUMN_ENDING_CHAR : #NEWLINE# #INDENT# content_buf . write ( self . COLUMN_STARTING_CHAR ) #NEWLINE# content_buf . write ( blob ) #NEWLINE# content_buf . write ( content_buf . COLUMN_ENDING_CHAR ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# blob = blob . rstrip ( ) #NEWLINE# if blob : #NEWLINE# #INDENT# content_buf . write ( self . COLUMN_STARTING_CHAR ) #NEWLINE# content_buf . write ( blob ) #NEWLINE# #UNINDENT# #UNINDENT# if ( ( i + 1 ) != row_count ) : #NEWLINE# #INDENT# content_buf . write ( self . LINE_SEP ) #NEWLINE# #UNINDENT# #UNINDENT# content_buf . write ( self . LINE_SEP ) #NEWLINE# content_buf . write ( header_footer_buf . getvalue ( ) ) #NEWLINE# #UNINDENT# return content_buf . getvalue ( )