MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / execute

Method execute

keepercommander/commands/folder.py:424–462  ·  view source on GitHub ↗
(self, params, **kwargs)

Source from the content-addressed store, hash-verified

422 return tree_parser
423
424 def execute(self, params, **kwargs):
425 folder_name = kwargs['folder'] if 'folder' in kwargs else None
426 verbose = kwargs.get('verbose', False)
427 records = kwargs.get('records')
428 shares = kwargs.get('shares')
429 nsf_shares = kwargs.get('nsf_shares')
430 fmt = kwargs.get('format') or 'table'
431 show_key = bool(shares or nsf_shares)
432 hide_key = kwargs.get('hide_shares_key', not show_key)
433 title = kwargs.get('title')
434 trees = []
435 if folder_name in params.folder_cache:
436 folder = params.folder_cache.get(folder_name)
437 trees.append(formatted_tree(
438 params, folder, verbose=verbose, show_records=records, shares=shares,
439 nsf_shares=nsf_shares, hide_shares_key=hide_key, title=title, fmt=fmt))
440 else:
441 folders, pattern = try_resolve_path(params, folder_name, find_all_matches=True)
442 if not pattern:
443 for idx, folder in enumerate(folders):
444 trees.append(formatted_tree(
445 params, folder, verbose=verbose, show_records=records, shares=shares,
446 nsf_shares=nsf_shares, hide_shares_key=hide_key or idx > 0, title=title,
447 fmt=fmt))
448 else:
449 raise CommandError('tree', f'Folder {folder_name} not found')
450 if fmt == 'json':
451 payload = trees[0] if len(trees) == 1 else {'trees': [t for t in trees if t]}
452 text = _tree_json_dumps(payload)
453 output = kwargs.get('output')
454 if output:
455 _, ext = os.path.splitext(output)
456 path = output if ext else output + '.json'
457 with open(path, 'w', encoding='utf-8') as fd:
458 fd.write(text)
459 fd.write('\n')
460 logging.info('Report path: %s', os.path.abspath(path))
461 return None
462 return text
463
464
465class FolderRenameCommand(Command):

Callers 1

test_treeMethod · 0.95

Calls 6

formatted_treeFunction · 0.85
try_resolve_pathFunction · 0.85
_tree_json_dumpsFunction · 0.85
getMethod · 0.80
CommandErrorClass · 0.70
infoMethod · 0.45

Tested by 1

test_treeMethod · 0.76