Added save command

This commit is contained in:
DiG 2022-01-17 16:11:01 +01:00
parent f64f306368
commit 162fb1e6ce
1 changed files with 13 additions and 8 deletions

View File

@ -328,11 +328,9 @@ def lookup( model, domains ):
# stack.append({ 'model': model, 'id': inst.id, 'file': filename, 'data': size })
stack.append( tree )
# return stack
jlog( stack )
# return [ flatten_stack( obj ) for obj in stack ]
return flatten_stack( stack )
# return list(flatten( flatten_stack( stack ) ))
return stack
# return flatten_stack( stack )
def flatten_stack( data ):
flat = []
@ -350,9 +348,9 @@ def flatten_stack( data ):
# eprint( 'is a list')
for item in obj:
# eprint( 'item: ', item, type(item))
if type(item) in (str,unicode):
# if type(item) in (str,unicode):
# eprint( 'sub item is a str')
flat.append( item )
# flat.append( item )
if type(item) == dict:
# eprint( 'sub item is a dict')
flatten( item )
@ -473,9 +471,16 @@ def export_json( model, domains ):
def save( model, domains ):
force = OPTS['force'] if 'force' in OPTS else False
models = lookup( model, domains )
models = flatten_stack( lookup( model, domains ) )
unique_models = list(set(models))
return unique_models
jlog( unique_models )
to_browse = {}
for muid in unique_models:
model, id = muid.split('/')
to_browse[model] = [] if not model in to_browse
to_browse[model] += id
return to_browse
# AUTO EXEC