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

Function try_resolve_path

keepercommander/subfolder.py:146–178  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

144
145
146def try_resolve_path(params, path, find_all_matches=False):
147 # type: (KeeperParams, str, bool) -> Tuple[Union[List[BaseFolderNode], BaseFolderNode, None], Optional[str]]
148 """
149 Look up the final keepercommander.subfolder.UserFolderNode and name of the final component(s).
150 Set find_all_matches = True to get a list of folders and component path
151
152 If a record, the final component is the record.
153 If existent folder(s), the final component is ''.
154 If a non-existent folder, the final component is the folders, joined with /, that do not (yet) exist..
155 """
156 if type(path) is not str:
157 path = ''
158
159 folder = (
160 params.folder_cache[params.current_folder]
161 if params.current_folder in params.folder_cache
162 else params.root_folder
163 )
164
165 folder, components = path_split(params, folder, path)
166
167 remainder, folders = lookup_path(params, folder, components)
168
169 tail = components[remainder:]
170
171 path = '/'.join(component.replace('/', '//') for component in tail)
172
173 # Return a 2-tuple of BaseFolderNode (or List[BaseFolderNode] if find_all_matches set to True), str
174 # The first is the folder/s containing the second, or the folder of the last component if the second is ''.
175 # The second is the final component of the path we're passed as an argument to this function. It could be a record, or
176 # a not-yet-existent directory.
177 return (folders, path) if find_all_matches \
178 else (next(iter(folders)) if folders else None, path)
179
180
181def get_folder_uids(params, name): # type: (KeeperParams, str or None) -> Set[Optional[str]]

Callers 15

get_folder_uidsFunction · 0.85
exportFunction · 0.85
find_recordFunction · 0.85
executeMethod · 0.85
executeMethod · 0.85
executeMethod · 0.85
executeMethod · 0.85
executeMethod · 0.85
executeMethod · 0.85
executeMethod · 0.85
executeMethod · 0.85
resolve_single_recordMethod · 0.85

Calls 2

path_splitFunction · 0.85
lookup_pathFunction · 0.85

Tested by

no test coverage detected