Revision 0f383dcc kamaki/cli/utils/__init__.py

b/kamaki/cli/utils/__init__.py
57 57
    suggest['ansicolors']['active'] = True
58 58

  
59 59

  
60
def _print(w):
61
    """Print wrapper is used to help unittests check what is printed"""
62
    print w
63

  
64

  
60 65
def suggest_missing(miss=None, exclude=[]):
61 66
    global suggest
62 67
    sgs = dict(suggest)
......
116 121

  
117 122
    :param data: json-dumpable data
118 123
    """
119
    print(dumps(data, indent=INDENT_TAB))
124
    _print(dumps(data, indent=INDENT_TAB))
120 125

  
121 126

  
122 127
def pretty_dict(d, *args, **kwargs):
......
156 161
        print_str += '%s.' % (i + 1) if with_enumeration else ''
157 162
        print_str += '%s:' % k
158 163
        if isinstance(v, dict):
159
            print print_str
164
            _print(print_str)
160 165
            print_dict(
161 166
                v, exclude, indent + INDENT_TAB,
162 167
                recursive_enumeration, recursive_enumeration)
163 168
        elif isinstance(v, list) or isinstance(v, tuple):
164
            print print_str
169
            _print(print_str)
165 170
            print_list(
166 171
                v, exclude, indent + INDENT_TAB,
167 172
                recursive_enumeration, recursive_enumeration)
168 173
        else:
169
            print '%s %s' % (print_str, v)
174
            _print('%s %s' % (print_str, v))
170 175

  
171 176

  
172 177
def print_list(
......
195 200
        'print_list prinbts a list or tuple')
196 201
    assert indent >= 0, 'print_list indent must be >= 0'
197 202

  
198
    counter = 0
199 203
    for i, item in enumerate(l):
200 204
        print_str = ' ' * indent
201 205
        print_str += '%s.' % (i + 1) if with_enumeration else ''
202 206
        if isinstance(item, dict):
203 207
            if with_enumeration:
204
                print print_str
205
            elif counter and counter < len(l):
206
                print
208
                _print(print_str)
209
            elif i and i < len(l):
210
                _print('')
207 211
            print_dict(
208 212
                item, exclude,
209 213
                indent + (INDENT_TAB if with_enumeration else 0),
210 214
                recursive_enumeration, recursive_enumeration)
211 215
        elif isinstance(item, list) or isinstance(item, tuple):
212 216
            if with_enumeration:
213
                print print_str
214
            elif counter and counter < len(l):
215
                print
217
                _print(print_str)
218
            elif i and i < len(l):
219
                _print()
216 220
            print_list(
217 221
                item, exclude, indent + INDENT_TAB,
218 222
                recursive_enumeration, recursive_enumeration)
......
220 224
            item = ('%s' % item).strip()
221 225
            if item in exclude:
222 226
                continue
223
            print '%s%s' % (print_str, item)
224
        counter += 1
227
            _print('%s%s' % (print_str, item))
225 228

  
226 229

  
227 230
def page_hold(index, limit, maxlen):

Also available in: Unified diff