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

Function lookup_path

keepercommander/subfolder.py:153–175  ·  view source on GitHub ↗

Lookup path of components within the folder cache. Get all the folders starting from the left end of component, plus the index of the first component that isn't present in the folder cache.

(params, folder, components, find_all_matches=False,
                raise_on_ambiguous=False)

Source from the content-addressed store, hash-verified

151
152
153def lookup_path(params, folder, components, find_all_matches=False,
154 raise_on_ambiguous=False):
155 # type: (KeeperParams, BaseFolderNode, List[Optional[str]]) -> Tuple[int, List[Optional[BaseFolderNode]]]
156 """
157 Lookup path of components within the folder cache.
158
159 Get all the folders starting from the left end of component, plus the index of the first component that isn't
160 present in the folder cache.
161 """
162 remainder = 0
163 folders = [folder]
164 for index, component in enumerate(components):
165 child_folders = contained_folders(params, folders, component)
166 if not child_folders:
167 break
168 if len(child_folders) > 1:
169 if raise_on_ambiguous:
170 raise FolderPathAmbiguousError(component)
171 if not find_all_matches:
172 return remainder, None
173 folders = child_folders
174 remainder = index + 1
175 return remainder, folders
176
177
178def is_abs_path(path_string):

Callers 2

try_resolve_pathFunction · 0.85

Calls 2

contained_foldersFunction · 0.85

Tested by

no test coverage detected