Added module renderers json tsv csv xml
This commit is contained in:
parent
65dfebf43c
commit
f8cdfff640
|
@ -1,5 +1,5 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
import json as JSON
|
||||||
|
|
||||||
# TABLE VIEW COLUMNS
|
# TABLE VIEW COLUMNS
|
||||||
cols = {
|
cols = {
|
||||||
|
@ -15,6 +15,10 @@ def tsv( *fields ):
|
||||||
def csv( *fields ):
|
def csv( *fields ):
|
||||||
print( *[ '"' + f.replace('"','\\"') + '"' for f in fields ], sep=',' )
|
print( *[ '"' + f.replace('"','\\"') + '"' for f in fields ], sep=',' )
|
||||||
|
|
||||||
|
def json( obj ):
|
||||||
|
print( JSON.dumps(obj, indent=4) ) #"\t") )
|
||||||
|
|
||||||
|
|
||||||
def render_tsv( model, list ):
|
def render_tsv( model, list ):
|
||||||
|
|
||||||
if model in cols:
|
if model in cols:
|
||||||
|
@ -40,7 +44,7 @@ def render_csv( model, list ):
|
||||||
csv( *[ obj[col] for col in _cols] )
|
csv( *[ obj[col] for col in _cols] )
|
||||||
|
|
||||||
def render_json( model, list ):
|
def render_json( model, list ):
|
||||||
jlog( list )
|
json( list )
|
||||||
|
|
||||||
#def render_json( model, obj ):
|
#def render_json( model, obj ):
|
||||||
def render( opts, model, list ): # +format=json,xml,csv +json +tsv
|
def render( opts, model, list ): # +format=json,xml,csv +json +tsv
|
||||||
|
|
Loading…
Reference in New Issue