mercurial/formatter.py
changeset 46769 67a2ecea8bd9
parent 45320 4aa484efc926
child 46819 d4ba4d51f85f
equal deleted inserted replaced
46768:3a8cf5b9c820 46769:67a2ecea8bd9
   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