Revision a517ff50 kamaki/cli/utils.py
b/kamaki/cli/utils.py | ||
---|---|---|
99 | 99 |
|
100 | 100 |
counter = 1 |
101 | 101 |
for key, val in sorted(d.items()): |
102 |
key = '%s' % key |
|
102 | 103 |
if key in exclude: |
103 | 104 |
continue |
104 | 105 |
print_str = '' |
... | ... | |
106 | 107 |
print_str = '%s. ' % counter |
107 | 108 |
counter += 1 |
108 | 109 |
print_str = '%s%s' % (' ' * (ident - len(print_str)), print_str) |
109 |
print_str += ('%s' % key).strip()
|
|
110 |
print_str += ' ' * (margin - len(unicode(key).strip()))
|
|
110 |
print_str += key.strip()
|
|
111 |
print_str += ' ' * (margin - len(key.strip()))
|
|
111 | 112 |
print_str += ': ' |
112 | 113 |
if isinstance(val, dict): |
113 | 114 |
print(print_str) |
... | ... | |
126 | 127 |
with_enumeration=recursive_enumeration, |
127 | 128 |
recursive_enumeration=recursive_enumeration) |
128 | 129 |
else: |
129 |
print print_str + ' ' + unicode(val).strip()
|
|
130 |
print print_str + ' ' + ('%s' % val).strip()
|
|
130 | 131 |
|
131 | 132 |
|
132 | 133 |
def print_list( |
... | ... | |
158 | 159 |
isinstance(item, list) or |
159 | 160 |
item in exclude)) |
160 | 161 |
except ValueError: |
161 |
margin = (2 + len(unicode(len(l)))) if enumerate else 1
|
|
162 |
margin = (2 + len(('%s' % len(l)))) if enumerate else 1
|
|
162 | 163 |
|
163 | 164 |
counter = 1 |
164 | 165 |
prefix = '' |
... | ... | |
242 | 243 |
if isinstance(item, dict): |
243 | 244 |
title = sorted(set(title).intersection(item.keys())) |
244 | 245 |
if with_redundancy: |
245 |
header = ' '.join(unicode(item[key]) for key in title)
|
|
246 |
header = ' '.join('%s' % item[key] for key in title)
|
|
246 | 247 |
else: |
247 |
header = ' '.join(unicode(item.pop(key)) for key in title)
|
|
248 |
header = ' '.join('%s' % item.pop(key) for key in title)
|
|
248 | 249 |
print(bold(header)) |
249 | 250 |
if isinstance(item, dict): |
250 | 251 |
print_dict(item, ident=1) |
... | ... | |
305 | 306 |
f.write('\n') |
306 | 307 |
list2file(v, f, depth + 1) |
307 | 308 |
else: |
308 |
f.write(' %s\n' % unicode(v))
|
|
309 |
f.write(' %s\n' % v)
|
|
309 | 310 |
|
310 | 311 |
|
311 | 312 |
def list2file(l, f, depth=1): |
... | ... | |
315 | 316 |
elif isinstance(item, list): |
316 | 317 |
list2file(item, f, depth + 1) |
317 | 318 |
else: |
318 |
f.write('%s%s\n' % ('\t' * depth, unicode(item)))
|
|
319 |
f.write('%s%s\n' % ('\t' * depth, item))
|
|
319 | 320 |
|
320 | 321 |
# Split input auxiliary |
321 | 322 |
|
Also available in: Unified diff