def models_to_table(obj, params=True):
    r"""
    Converts a ModelsDict object to a ReST compatible table

    Parameters
    ----------
    obj : OpenPNM object
        Any object that has a ``models`` attribute

    params : boolean
        Indicates whether or not to include a list of parameter
        values in the table.  Set to False for just a list of models, and
        True for a more verbose table with all parameter values.
    """
    if not hasattr(obj, 'models'):
        raise Exception('Received object does not have any models')
    row = '+' + '-'*4 + '+' + '-'*22 + '+' + '-'*18 + '+' + '-'*26 + '+'
    fmt = '{0:1s} {1:2s} {2:1s} {3:20s} {4:1s} {5:16s} {6:1s} {7:24s} {8:1s}'
    lines = []
    lines.append(row)
    lines.append(fmt.format('|', '#', '|', 'Property Name', '|', 'Parameter',
                            '|', 'Value', '|'))
    lines.append(row.replace('-', '='))
    for i, item in enumerate(obj.models.keys()):
        prop = item
        if len(prop) > 20:
            prop = item[:17] + "..."
        temp = obj.models[item].copy()
        model = str(temp.pop('model')).split(' ')[1]
        lines.append(fmt.format('|', str(i+1), '|', prop, '|', 'model:',
                                '|', model, '|'))
        lines.append(row)
        if params:
            for param in temp.keys():
                p1 = param
                if len(p1) > 16:
                    p1 = p1[:14] + '...'
                p2 = str(temp[param])
                if len(p2) > 24:
                    p2 = p2[:21] + '...'
                lines.append(fmt.format('|', '', '|', '', '|', p1, '|',
                                        p2, '|'))
                lines.append(row)
    return '\n'.join(lines)
def models_to_table ( obj , params = True ) : if not hasattr ( obj , 'models' ) : raise Exception ( 'Received object does not have any models' ) row = '+' + '-' * 4 + '+' + '-' * 22 + '+' + '-' * 18 + '+' + '-' * 26 + '+' fmt = '{0:1s} {1:2s} {2:1s} {3:20s} {4:1s} {5:16s} {6:1s} {7:24s} {8:1s}' lines = [ ] lines . append ( row ) lines . append ( fmt . format ( '|' , '#' , '|' , 'Property Name' , '|' , 'Parameter' , '|' , 'Value' , '|' ) ) lines . append ( row . replace ( '-' , '=' ) ) for i , item in enumerate ( obj . models . keys ( ) ) : prop = item if len ( prop ) > 20 : prop = item [ : 17 ] + "..." temp = obj . models [ item ] . copy ( ) model = str ( temp . pop ( 'model' ) ) . split ( ' ' ) [ 1 ] lines . append ( fmt . format ( '|' , str ( i + 1 ) , '|' , prop , '|' , 'model:' , '|' , model , '|' ) ) lines . append ( row ) if params : for param in temp . keys ( ) : p1 = param if len ( p1 ) > 16 : p1 = p1 [ : 14 ] + '...' p2 = str ( temp [ param ] ) if len ( p2 ) > 24 : p2 = p2 [ : 21 ] + '...' lines . append ( fmt . format ( '|' , '' , '|' , '' , '|' , p1 , '|' , p2 , '|' ) ) lines . append ( row ) return '\n' . join ( lines )
r"""
    Converts a ModelsDict object to a ReST compatible table

    Parameters
    ----------
    obj : OpenPNM object
        Any object that has a ``models`` attribute

    params : boolean
        Indicates whether or not to include a list of parameter
        values in the table.  Set to False for just a list of models, and
        True for a more verbose table with all parameter values.