The Link class#
Aliases#
halerium.core.graph.Link
- class Link(name=None, frame=None)#
The halerium Link class.
This class holds links between entities or variables. The user is not meant to create Link instances directly, but to use the link function instead.
The halerium Link class.
- Parameters:
name (str, optional) – The name of the instance. If None it is chosen automatically. The default is None.
frame – The frame for name injection.
- accept(visitor)#
Accept visitor.
- Parameters:
visitor – The visitor to accept.
- Returns:
The result of the visit.
- Return type:
result
- destruct(_recursion=False)#
Destructs the link.
- Parameters:
_recursion (bool, optional) – Argument for handling recursion. Not meant to be altered by the user.
- establish_link()#
Established the link by calling the link method of its target.
- get_containing_class(scopetor_cls)#
Get the closest parent that is of a specific type.
- Parameters:
scopetor_cls (scopetor subclass) – The scopetor subclass of which the next containing instance is to be found.
- Raises:
ValueError – If no containing scopetor of type scopetor_cls is found, an error is raised.
- Returns:
scope – The containing scopetor of type scopetor_cls.
- Return type:
scopetor_cls
Examples
>>> from halerium.core import Graph, Entity >>> g = Graph("g") >>> with g: >>> e = Entity("e") >>> with e: >>> Entity("m") >>> g.e.m.get_containing_class(Graph) is g True >>> assert g.e.m.get_containing_class(Entity) is g.e True
- property global_name#
The global name of the scopee.
The global name is a chain of all parent names of this scopee separated by ‘/’ characters.
- is_child_of(scopetor, include_self=True)#
Whether is child of scopetor.
This method checks whether the scopee is a (grand-) child of a given scopetor.
- Parameters:
scopetor (Scopetor) – The (possible) parent scopetor
include_self (bool) – If True, a.is_child_of(a) would return True. If False, a.is_child_of(a) would return False.
- Returns:
Whether self is a (grand-)child of scopetor or not.
- Return type:
bool
- property name#
The name of the scopee.
- property source#
The link’s source.
- property target#
The link’s target.