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