def set_parent(self, parent: Optional["Catalog_Type"]) -> None: """Sets the parent :class:`~pystac.Catalog` or :class:`~pystac.Collection` for this object. Args: parent : The parent object to set. Passing in None will clear the parent. """ self.remove_links(pystac.RelType.PARENT) if parent is not None: self.add_link(Link.parent(parent))
def set_parent(self, parent, link_type=None): """Sets the parent :class:`~pystac.Catalog` or :class:`~pystac.Collection` for this object. Args: parent (Catalog or Collection): The parent object to set. link_type (str): The link type (see :class:`~pystac.LinkType`) """ if not link_type: prev = self.get_single_link('parent') if prev is not None: link_type = prev.link_type else: link_type = LinkType.ABSOLUTE self.remove_links('parent') self.add_link(Link.parent(parent, link_type=link_type)) return self
def set_parent(self, parent): self.links = [l for l in self.links if l.rel != 'parent'] self.links.append(Link.parent(parent))