"""This module contains shorthand ``reference`` definitions. References are used in theconfiguration module to point to other locations in the Configuration object.Minimally a reference is a function that takes the configuration root and the currentnode as arguments, and returns another node in the configuration object:: def some_reference(root, here): return root.other.placeMore advanced usage of references will include custom reference errors."""importabc
[docs]classReference(abc.ABC):# noqa: B024""" Interface to create reference to pass to `bsb.config.ref` or `bsb.config.reflist` """def__call__(self,root,here):""" Function to retrieve the location of the reference :param root: root of the configuration object :param here: current node in the configuration object """returnhere
[docs]defup(self,here,to=None):""" Get the parent node of the configuration node ``here``. If ``to`` is provided, will search ``here``'s ascendants until one matches ``to``'s type. :param here: starting node :param to: type of the ascendant to find :return: The first matching parent node of ``here`` """iftoisNone:returnhere._config_parentwhilenotisinstance(here,to):try:here=here._config_parentexceptAttributeError:returnNonereturnhere
@property@abc.abstractmethoddeftype(self):# pragma: nocover""" Return the type of the reference """pass