MCPcopy Create free account
hub / github.com/PyTables/PyTables / create_external_link

Method create_external_link

tables/file.py:1703–1734  ·  view source on GitHub ↗

Create an external link. Create an external link to a *target* node with the given *name* in *where* location. *target* can be a node object in another file or a path string in the form 'file:/path/to/node'. If *createparents* is true, the intermediate groups requi

(
        self,
        where: Node | str,
        name: str,
        target: Node | str,
        createparents: bool = False,
    )

Source from the content-addressed store, hash-verified

1701 return slink
1702
1703 def create_external_link(
1704 self,
1705 where: Node | str,
1706 name: str,
1707 target: Node | str,
1708 createparents: bool = False,
1709 ) -> ExternalLink:
1710 """Create an external link.
1711
1712 Create an external link to a *target* node with the given *name*
1713 in *where* location. *target* can be a node object in another
1714 file or a path string in the form 'file:/path/to/node'. If
1715 *createparents* is true, the intermediate groups required for
1716 reaching *where* are created (the default is not doing so).
1717
1718 The returned node is an :class:`ExternalLink` instance.
1719
1720 """
1721 if not isinstance(target, str):
1722 if hasattr(target, "_v_pathname"): # quacks like a Node
1723 target = target._v_file.filename + ":" + target._v_pathname
1724 else:
1725 raise ValueError(
1726 "`target` has to be a string or a node object"
1727 )
1728 elif target.find(":/") == -1:
1729 raise ValueError("`target` must expressed as 'file:/path/to/node'")
1730 parentnode = self._get_or_create_path(where, createparents)
1731 elink = ExternalLink(parentnode, name, target)
1732 # Refresh children names in link's parent node
1733 parentnode._g_add_children_names()
1734 return elink
1735
1736 def _get_node(self, nodepath: str) -> Node | RootGroup:
1737 # The root node is always at hand.

Callers 2

_createFileMethod · 0.80
links.pyFile · 0.80

Calls 3

_get_or_create_pathMethod · 0.95
ExternalLinkClass · 0.85
_g_add_children_namesMethod · 0.80

Tested by 1

_createFileMethod · 0.64