Skip to content
Snippets Groups Projects

model.provider: Add AbstractObjectStore.get() method

Merged Michael Thies requested to merge enhancement/provider_get into master
2 files
+ 16
0
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 13
0
@@ -40,6 +40,19 @@ class AbstractObjectProvider(metaclass=abc.ABCMeta):
"""
pass
def get(self, identifier: Identifier, default: Optional[Identifiable] = None) -> Optional[Identifiable]:
"""
Find an object in this set by its identification, with fallback parameter
:param default: An object to be returned, if no object with the given identification is found
:return: The Identifiable object with the given identification in the provider. Otherwise the `default` object
or None, if none is given.
"""
try:
return self.get_identifiable(identifier)
except KeyError:
return default
_IT = TypeVar('_IT', bound=Identifiable)
Loading