Look up the final keepercommander.subfolder.UserFolderNode and name of the final component(s). Set find_all_matches = True to get a list of folders and component path If a record, the final component is the record. If existent folder(s), the final component is ''. If a non-exis
(params, path, find_all_matches=False,
raise_on_ambiguous=False)
| 191 | |
| 192 | |
| 193 | def try_resolve_path(params, path, find_all_matches=False, |
| 194 | raise_on_ambiguous=False): |
| 195 | # type: (KeeperParams, str, bool) -> Tuple[Union[List[BaseFolderNode], BaseFolderNode, None], Optional[str]] |
| 196 | """ |
| 197 | Look up the final keepercommander.subfolder.UserFolderNode and name of the final component(s). |
| 198 | Set find_all_matches = True to get a list of folders and component path |
| 199 | |
| 200 | If a record, the final component is the record. |
| 201 | If existent folder(s), the final component is ''. |
| 202 | If a non-existent folder, the final component is the folders, joined with /, that do not (yet) exist.. |
| 203 | """ |
| 204 | if type(path) is not str: |
| 205 | path = '' |
| 206 | |
| 207 | folder = ( |
| 208 | params.folder_cache[params.current_folder] |
| 209 | if params.current_folder in params.folder_cache |
| 210 | else params.root_folder |
| 211 | ) |
| 212 | |
| 213 | folder, components = path_split(params, folder, path) |
| 214 | |
| 215 | remainder, folders = lookup_path( |
| 216 | params, folder, components, |
| 217 | find_all_matches=find_all_matches, |
| 218 | raise_on_ambiguous=raise_on_ambiguous) |
| 219 | if folders is None: |
| 220 | return None |
| 221 | |
| 222 | tail = components[remainder:] |
| 223 | |
| 224 | path = '/'.join(component.replace('/', '//') for component in tail) |
| 225 | |
| 226 | # Return a 2-tuple of BaseFolderNode (or List[BaseFolderNode] if find_all_matches set to True), str |
| 227 | # The first is the folder/s containing the second, or the folder of the last component if the second is ''. |
| 228 | # The second is the final component of the path we're passed as an argument to this function. It could be a record, or |
| 229 | # a not-yet-existent directory. |
| 230 | return (folders, path) if find_all_matches \ |
| 231 | else (next(iter(folders)) if folders else None, path) |
| 232 | |
| 233 | |
| 234 | def get_folder_uids(params, name): # type: (KeeperParams, str or None) -> Set[Optional[str]] |
no test coverage detected