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

Method execute

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

Source from the content-addressed store, hash-verified

899 return True
900
901 def execute(self, params, **kwargs):
902 src_path = kwargs['src'] if 'src' in kwargs else None
903 dst_path = kwargs['dst'] if 'dst' in kwargs else None
904 error_command = 'mv' if self.is_move() else 'ln'
905
906 if not src_path or not dst_path:
907 parser = self.get_parser()
908 parser.print_help()
909 return
910
911 if dst_path in params.folder_cache:
912 dst_folder = params.folder_cache[dst_path]
913 else:
914 try:
915 dst = try_resolve_path(
916 params, dst_path, raise_on_ambiguous=True)
917 except FolderPathAmbiguousError as e:
918 raise CommandError(error_command, str(e))
919 if dst is None:
920 raise CommandError(error_command, 'Destination path should be existing folder')
921 dst_folder, name = dst
922 if len(name) > 0:
923 raise CommandError(error_command, 'Destination path should be existing folder')
924
925 source = [] # type: List[Tuple[BaseFolderNode, Optional[str]]] # (folder, record_uid)
926 if src_path in params.record_cache: # record UID
927 record_uid = src_path
928 src_folder = None
929 folder_uids = list(find_folders(params, record_uid))
930 if folder_uids:
931 if params.current_folder:
932 if params.current_folder in folder_uids:
933 src_folder = params.folder_cache[params.current_folder]
934 else:
935 if '' in params.subfolder_record_cache:
936 if record_uid in params.subfolder_record_cache['']:
937 src_folder = params.root_folder
938 if not src_folder:
939 src_folder = params.folder_cache[folder_uids[0]]
940 else:
941 src_folder = params.root_folder
942
943 if src_folder is dst_folder:
944 raise CommandError(error_command, 'Source and Destination folders are the same')
945 source.append((src_folder, record_uid))
946 elif src_path in params.folder_cache: # folder UID
947 src_folder = params.folder_cache[src_path]
948 if src_folder is dst_folder:
949 raise CommandError(error_command, 'Source and Destination folders are the same')
950 source.append((src_folder, None))
951 else:
952 try:
953 src = try_resolve_path(
954 params, src_path, raise_on_ambiguous=True)
955 except FolderPathAmbiguousError as e:
956 raise CommandError(error_command, str(e))
957 if src is None:
958 raise CommandError(error_command, 'Source path should be existing record or folder')

Calls 13

is_moveMethod · 0.95
get_parserMethod · 0.95
try_resolve_pathFunction · 0.85
find_foldersFunction · 0.85
get_transition_keyMethod · 0.80
communicateMethod · 0.80
CommandErrorClass · 0.70
print_helpMethod · 0.45
getMethod · 0.45
loadMethod · 0.45
infoMethod · 0.45