Added module renderers json tsv csv xml

This commit is contained in:
DiG 2022-01-16 19:13:27 +01:00
parent 65dfebf43c
commit f8cdfff640
1 changed files with 6 additions and 2 deletions

View File

@ -1,5 +1,5 @@
from __future__ import print_function
import json as JSON
# TABLE VIEW COLUMNS
cols = {
@ -15,6 +15,10 @@ def tsv( *fields ):
def csv( *fields ):
print( *[ '"' + f.replace('"','\\"') + '"' for f in fields ], sep=',' )
def json( obj ):
print( JSON.dumps(obj, indent=4) ) #"\t") )
def render_tsv( model, list ):
if model in cols:
@ -40,7 +44,7 @@ def render_csv( model, list ):
csv( *[ obj[col] for col in _cols] )
def render_json( model, list ):
jlog( list )
json( list )
#def render_json( model, obj ):
def render( opts, model, list ): # +format=json,xml,csv +json +tsv