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

Function find_parent_top_folder

keepercommander/subfolder.py:74–109  ·  view source on GitHub ↗

Find all top Shared Folders that will contain this record. Record can be in more than two folders by having a "link" which will present a record as a record with the same UID in more than one folder.

(params, record_uid)

Source from the content-addressed store, hash-verified

72
73
74def find_parent_top_folder(params, record_uid):
75
76 """
77 Find all top Shared Folders that will contain this record.
78 Record can be in more than two folders by having a "link" which
79 will present a record as a record with the same UID in more than
80 one folder.
81 """
82 contained_folder_uids = []
83
84 # Get all folders that might contain the given record
85 for fuid in params.subfolder_record_cache:
86 if fuid: # record is in root folder
87 if record_uid in params.subfolder_record_cache[fuid]:
88 contained_folder_uids.append(fuid)
89
90 shared_folders_containing_record = []
91
92 # if records that belong to folder are found then go
93 # through each one of them to get the share folder
94 for cfuid in contained_folder_uids:
95 if cfuid:
96 folder = params.folder_cache[cfuid]
97
98 # folder is already a shared folder
99 if isinstance(folder, SharedFolderNode):
100 shared_folders_containing_record.append(folder)
101 # folder is a sub-folder, let's get its pared shared folder
102 elif isinstance(folder, SharedFolderFolderNode):
103 shared_folder_uid = folder.shared_folder_uid
104 shared_folder = params.folder_cache[shared_folder_uid]
105 shared_folders_containing_record.append(shared_folder)
106 else:
107 logging.debug("Folder UID={} is not a shared folder".format(cfuid))
108
109 return shared_folders_containing_record
110
111
112def contained_folders(params, folders, component):

Callers 4

get_field_inputFunction · 0.85

Calls 2

formatMethod · 0.80
debugMethod · 0.45

Tested by

no test coverage detected