Source code for api.simulation.data_tables.partial_find_creator_setup

""" Base class for handling setting up data tables in loads, for particular implementations see
 :ref:`data table setup implementations documentation <data_tables>`"""

import typing

from more.api.exceptions.api_exception import StaleReferentError

# Replace with the correct interface as soon as program interfaces will be made independent of implementations
partial_find_creator_interface_type = typing.Any


[docs] class PartialFindCreatorSetup: def __init__(self, partial_find_creator_getter: typing.Callable[[], partial_find_creator_interface_type], partial_find_creator: partial_find_creator_interface_type): self._partial_find_creator_getter = partial_find_creator_getter self._initial_partial_find_creator = partial_find_creator def _get_wrapped_object(self): return self._initial_partial_find_creator def __getattribute__(self, name): current_partial_find_creator = object.__getattribute__(self, '_partial_find_creator_getter')() initial_partial_find_creator = object.__getattribute__(self, '_initial_partial_find_creator') if initial_partial_find_creator != current_partial_find_creator: raise StaleReferentError('This query config is stale and no longer valid, ' 'most probably the chosen data table changed') return object.__getattribute__(self, name)