(self, params, **kwargs)
| 1076 | return shortcut_list_parser |
| 1077 | |
| 1078 | def execute(self, params, **kwargs): |
| 1079 | records = ShortcutCommand.get_record_shortcuts(params) |
| 1080 | target = kwargs.get('target') |
| 1081 | to_show = set() |
| 1082 | if target: |
| 1083 | if target in params.record_cache: # record UID |
| 1084 | if target not in records: |
| 1085 | raise CommandError('shortcut-get', f'Record UID {target} does not have shortcuts') |
| 1086 | to_show.add(target) |
| 1087 | |
| 1088 | elif target in params.folder_cache: # folder UID |
| 1089 | for record_uid in records: |
| 1090 | if target in records[record_uid]: |
| 1091 | to_show.add(record_uid) |
| 1092 | |
| 1093 | else: |
| 1094 | path = try_resolve_path(params, target) |
| 1095 | if path is None: |
| 1096 | raise CommandError('shortcut-keep', 'Target path should be existing record or folder') |
| 1097 | folder, name = path |
| 1098 | if name: |
| 1099 | regex = re.compile(fnmatch.translate(name)).match |
| 1100 | folder_uid = folder.uid or '' |
| 1101 | if folder_uid in params.subfolder_record_cache: |
| 1102 | for record_uid in params.subfolder_record_cache[folder_uid]: |
| 1103 | if record_uid == name: |
| 1104 | if record_uid in records: |
| 1105 | if folder_uid in records[record_uid]: |
| 1106 | to_show.add(record_uid) |
| 1107 | else: |
| 1108 | record = vault.KeeperRecord.load(params, record_uid) |
| 1109 | if isinstance(record, vault.PasswordRecord) or isinstance(record, vault.TypedRecord): |
| 1110 | if regex(record.title): |
| 1111 | if record_uid in records: |
| 1112 | if folder_uid in records[record_uid]: |
| 1113 | to_show.add(record_uid) |
| 1114 | else: |
| 1115 | folder_uid = folder.uid or '' |
| 1116 | if folder_uid in params.subfolder_record_cache: |
| 1117 | for record_uid in params.subfolder_record_cache[folder_uid]: |
| 1118 | if record_uid in records: |
| 1119 | if folder_uid in records[record_uid]: |
| 1120 | to_show.add(record_uid) |
| 1121 | else: |
| 1122 | logging.info('Displaying all shortcuts') |
| 1123 | to_show.update(records.keys()) |
| 1124 | |
| 1125 | table = [] |
| 1126 | json_headers = ['record_uid', 'record_title', 'folder'] |
| 1127 | headers = ['Record UID', 'Record Title', 'Folder'] |
| 1128 | fmt = kwargs.get('format') |
| 1129 | for record_uid in to_show: |
| 1130 | record = vault.KeeperRecord.load(params, record_uid) |
| 1131 | if record: |
| 1132 | folders = [params.folder_cache.get(x, params.root_folder) for x in records[record_uid]] |
| 1133 | folders.sort(key=lambda x: x.name or '') |
| 1134 | f = [] |
| 1135 | for x in folders: |
nothing calls this directly
no test coverage detected