equal
deleted
inserted
replaced
176 '''convert iterable to appropriate list format''' |
176 '''convert iterable to appropriate list format''' |
177 return list(data) |
177 return list(data) |
178 |
178 |
179 |
179 |
180 class baseformatter(object): |
180 class baseformatter(object): |
|
181 |
|
182 # set to True if the formater output a strict format that does not support |
|
183 # arbitrary output in the stream. |
|
184 strict_format = False |
|
185 |
181 def __init__(self, ui, topic, opts, converter): |
186 def __init__(self, ui, topic, opts, converter): |
182 self._ui = ui |
187 self._ui = ui |
183 self._topic = topic |
188 self._topic = topic |
184 self._opts = opts |
189 self._opts = opts |
185 self._converter = converter |
190 self._converter = converter |
416 baseformatter.end(self) |
421 baseformatter.end(self) |
417 self._out.write(cborutil.BREAK) |
422 self._out.write(cborutil.BREAK) |
418 |
423 |
419 |
424 |
420 class jsonformatter(baseformatter): |
425 class jsonformatter(baseformatter): |
|
426 |
|
427 strict_format = True |
|
428 |
421 def __init__(self, ui, out, topic, opts): |
429 def __init__(self, ui, out, topic, opts): |
422 baseformatter.__init__(self, ui, topic, opts, _nullconverter) |
430 baseformatter.__init__(self, ui, topic, opts, _nullconverter) |
423 self._out = out |
431 self._out = out |
424 self._out.write(b"[") |
432 self._out.write(b"[") |
425 self._first = True |
433 self._first = True |