Added module renderers json tsv csv xml

This commit is contained in:
DiG 2022-01-16 19:21:02 +01:00
parent f8cdfff640
commit ec48c3b5df
1 changed files with 4 additions and 4 deletions

View File

@ -44,15 +44,15 @@ def render_csv( model, list ):
csv( *[ obj[col] for col in _cols] )
def render_json( model, list ):
json( list )
json( list.read )
#def render_json( model, obj ):
def render( opts, model, list ): # +format=json,xml,csv +json +tsv
if ( 'json' in opts and opts['json'] ) or ( 'format' in opts and 'json' in opts['format'] ):
render_json( model, list )
if ( 'tsv' in opts and opts['tsv'] ) or ( 'format' in opts and 'tsv' in opts['format'] ):
elif ( 'tsv' in opts and opts['tsv'] ) or ( 'format' in opts and 'tsv' in opts['format'] ):
render_tsv( model, list )
if ( 'csv' in opts and opts['csv'] ) or ( 'format' in opts and 'csv' in opts['format'] ):
elif ( 'csv' in opts and opts['csv'] ) or ( 'format' in opts and 'csv' in opts['format'] ):
render_csv( model, list )
# if ( 'xml' in opts and opts['xml'] ) or ( 'format' in opts and 'xml' in opts['format'] ):
# elif ( 'xml' in opts and opts['xml'] ) or ( 'format' in opts and 'xml' in opts['format'] ):
# render_xml( model, list )