Revision db950b10 kamaki/cli/utils.py

b/kamaki/cli/utils.py
73 73
    if not isinstance(d, dict):
74 74
        raise CLIError(message='Cannot dict_print a non-dict object')
75 75

  
76
    margin = max(len(unicode(key).strip())\
77
        for key in d.keys() if key not in exclude)
76
    if d:
77
        margin = max(len(unicode(key).strip())\
78
            for key in d.keys() if key not in exclude)
78 79

  
79 80
    for key, val in sorted(d.items()):
80 81
        if key in exclude:
......
97 98
    if not isinstance(l, list):
98 99
        raise CLIError(message='Cannot list_print a non-list object')
99 100

  
100
    margin = max(len(unicode(item).strip())\
101
        for item in l if item not in exclude)
101
    if l:
102
        margin = max(len(unicode(item).strip())\
103
            for item in l if item not in exclude)
102 104

  
103 105
    for item in sorted(l):
104 106
        if item in exclude:

Also available in: Unified diff