Beispiel #1
0
def _get_str(x, informal):
    from contracts.interface import describe_value_multiline
    if informal:
        s = str(x)
    else:
        s = describe_value_multiline(x)
    return s
Beispiel #2
0
def _get_str(x, informal):
    from contracts.interface import describe_value_multiline
    if informal:
        s = str(x)
    else:
        s = describe_value_multiline(x)
    return s
Beispiel #3
0
def format_obs(d):
    """ Shows objects values and typed for the given dictionary """
    if not d:
        return ''
    from contracts.interface import describe_value_multiline

    maxlen = 0
    for name in d:
        maxlen = max(len(name), maxlen)

    def pad(pre):
        return ' ' * (maxlen - len(pre)) + pre

    res = ''
    for i, (name, value) in enumerate(d.items()):
        prefix = pad('%s: ' % name)
        if i > 0:
            res += '\n'
        res += indent(describe_value_multiline(value), ' ', first=prefix)

    return res
Beispiel #4
0
def format_obs(d):
    """ Shows objects values and typed for the given dictionary """
    if not d:
        return ''
    from contracts.interface import describe_value_multiline


    
    maxlen = 0
    for name in d:
        maxlen = max(len(name), maxlen)
        
    def pad(pre):
        return ' ' * (maxlen-len(pre)) + pre
    
    res = ''
    for i, (name, value) in enumerate(d.items()):
        prefix = pad('%s: ' % name)
        if i > 0:
            res += '\n'
        res +=  indent(describe_value_multiline(value), 
                             ' ', first=prefix)
        
    return res