localpdb/plugins/utils/MakeMultimer.py
def tableFormat(titleList, dataLists, rowJoiner='  '):
    '''
    generic table formatting, adapted to this simple case.
    first row contains titles, all others contain values.
    '''
    # first, make sure all numeric entries get properly converted
    rawRows = dataLists
    rowLists = [titleList[:]]
    for r in rawRows:
        rowLists.append([str(field) for field in r])
    # bring all lists to equal length
    ml = max([len(r) for r in rowLists])
    for r in rowLists:
        if len(r) < ml:
            r.extend([''] * (ml - len(r)))
    widths = [] # determine required width for each column
    for field in range(ml):
        width = max([len(row[field]) for row in rowLists]) + len(rowJoiner)
        widths.append(width)
    joinedRows = []
    for row in rowLists:
        nr = [(s + rowJoiner).rjust(widths[i]) for i, s in enumerate(row)]
        joinedRows.append(''.join(nr).rstrip())  # remove trailing spaces
    l = max([len(r) for r in joinedRows])
    s = '-' * l
    joinedRows.append(s)
    joinedRows.insert(1,s)
    joinedRows.insert(0,s)
    return joinedRows

    generic table formatting, adapted to this simple case.
    first row contains titles, all others contain values.
    
generic table formatting, adapted to this simple case.
first row contains titles, all others contain values.
generic table formatting adapted to this simple case . first row contains titles all others contain values .
def tableFormat(titleList, dataLists, rowJoiner='  '):
    rawRows = dataLists
    rowLists = [titleList[:]]
    for r in rawRows:
        rowLists.append([str(field) for field in r])
    ml = max([len(r) for r in rowLists])
    for r in rowLists:
        if len(r) < ml:
            r.extend([''] * (ml - len(r)))
    widths = [] 
    for field in range(ml):
        width = max([len(row[field]) for row in rowLists]) + len(rowJoiner)
        widths.append(width)
    joinedRows = []
    for row in rowLists:
        nr = [(s + rowJoiner).rjust(widths[i]) for i, s in enumerate(row)]
        joinedRows.append(''.join(nr).rstrip())  
    l = max([len(r) for r in joinedRows])
    s = '-' * l
    joinedRows.append(s)
    joinedRows.insert(1,s)
    joinedRows.insert(0,s)
    return joinedRows
def tableFormat ( titleList , dataLists , rowJoiner = '  ' ) : rawRows = dataLists rowLists = [ titleList [ : ] ] for r in rawRows : rowLists . append ( [ str ( field ) for field in r ] ) ml = max ( [ len ( r ) for r in rowLists ] ) for r in rowLists : if len ( r ) < ml : r . extend ( [ '' ] * ( ml - len ( r ) ) ) widths = [ ] for field in range ( ml ) : width = max ( [ len ( row [ field ] ) for row in rowLists ] ) + len ( rowJoiner ) widths . append ( width ) joinedRows = [ ] for row in rowLists : nr = [ ( s + rowJoiner ) . rjust ( widths [ i ] ) for i , s in enumerate ( row ) ] joinedRows . append ( '' . join ( nr ) . rstrip ( ) ) l = max ( [ len ( r ) for r in joinedRows ] ) s = '-' * l joinedRows . append ( s ) joinedRows . insert ( 1 , s ) joinedRows . insert ( 0 , s ) return joinedRows
generic table formatting, adapted to this simple case.
generic table formatting adapted to this simple case .
'''
    generic table formatting, adapted to this simple case.
    first row contains titles, all others contain values.
    ''' # first, make sure all numeric entries get properly converted # bring all lists to equal length # determine required width for each column # remove trailing spaces
titleList
dataLists
rowJoiner