def update_from_lid(lid: LID) -> LIDVID: # Find the path corresponding to this LID. path = vv_lid_path(lid) # First, update all the children recursively. Get their # LIDs by extending this LID with the names of the # subdirectories of path. That handles directories. child_lidvids: Set[LIDVID] = { update_from_lid(lid.extend_lid(strip_segment(name))) for name in single_version_fs.listdir(path) if is_segment(name) } # Now look at files. We create a VersionContents object # from the set of new LIDVIDs and all the files contained # in the component's directory. contents = VersionContents.create_from_lidvids_and_dirpath( child_lidvids, single_version_fs, path) # Now we ask the Multiversioned to insert these contents # as a new version if needed. It returns the new LIDVID # if a new LIDVID is needed, otherwise it returns the old # one. return self.add_contents_if(is_new, lid, contents, False)
def _extend_lidvid(lid: LID, vid: VID, segment: str) -> str: new_lid = lid.extend_lid(segment) new_lidvid = LIDVID.create_from_lid_and_vid(new_lid, vid) return str(new_lidvid)