Bases: ContextAware
Context-aware metadata provider.
The class implements the Mapping
protocol as a means of giving convenient access to
the metadata it contains.
Source code in holm/modules/_metadata.py
| class Metadata(ContextAware):
"""
Context-aware metadata provider.
The class implements the `Mapping` protocol as a means of giving convenient access to
the metadata it contains.
"""
__slots__ = ("_metadata",)
def __init__(self, metadata: MetadataMapping) -> None:
"""
Initialization.
Arguments:
metadata: The actual metadata mapping.
"""
self._metadata = metadata
"""The metadata mapping."""
@overload
def get(self, key: Any, default: None = None) -> Any | None: ...
@overload
def get(self, key: Any, default: Any) -> Any: ...
def get(self, key: Any, default: Any | None = None) -> Any | None:
"""Implements `Mapping.get()`."""
return self._metadata.get(key, default)
def __contains__(self, key: Any) -> bool:
"""Implements the `Container` protocol."""
return key in self._metadata
def __eq__(self, other: Any) -> bool:
return isinstance(other, Metadata) and self._metadata == other._metadata
def __getitem__(self, key: Any) -> Any:
"""Implements the `Sequence` protocol."""
return self._metadata[key]
def __iter__(self) -> Iterator[Any]:
"""Implements the `Iterable` protocol."""
return iter(self._metadata)
def __len__(self) -> int:
"""Implements the `Sized` protocol."""
return len(self._metadata)
def __ne__(self, other: Any) -> bool:
return not self.__eq__(other)
def items(self) -> ItemsView[Any, Any]:
"""Implements `Mapping.items()`."""
return self._metadata.items()
def keys(self) -> KeysView[Any]:
"""Implements `Mapping.keys()`."""
return self._metadata.keys()
def values(self) -> ValuesView[Any]:
"""Implements `Mapping.values()`."""
return self._metadata.values()
|
Implements the Container
protocol.
Source code in holm/modules/_metadata.py
| def __contains__(self, key: Any) -> bool:
"""Implements the `Container` protocol."""
return key in self._metadata
|
Implements the Sequence
protocol.
Source code in holm/modules/_metadata.py
| def __getitem__(self, key: Any) -> Any:
"""Implements the `Sequence` protocol."""
return self._metadata[key]
|
Implements the Iterable
protocol.
Source code in holm/modules/_metadata.py
| def __iter__(self) -> Iterator[Any]:
"""Implements the `Iterable` protocol."""
return iter(self._metadata)
|
Implements the Sized
protocol.
Source code in holm/modules/_metadata.py
| def __len__(self) -> int:
"""Implements the `Sized` protocol."""
return len(self._metadata)
|
get(key: Any, default: None = None) -> Any | None
get(key: Any, default: Any) -> Any
Implements Mapping.get()
.
Source code in holm/modules/_metadata.py
| def get(self, key: Any, default: Any | None = None) -> Any | None:
"""Implements `Mapping.get()`."""
return self._metadata.get(key, default)
|
Implements Mapping.items()
.
Source code in holm/modules/_metadata.py
| def items(self) -> ItemsView[Any, Any]:
"""Implements `Mapping.items()`."""
return self._metadata.items()
|
Implements Mapping.keys()
.
Source code in holm/modules/_metadata.py
| def keys(self) -> KeysView[Any]:
"""Implements `Mapping.keys()`."""
return self._metadata.keys()
|
Implements Mapping.values()
.
Source code in holm/modules/_metadata.py
| def values(self) -> ValuesView[Any]:
"""Implements `Mapping.values()`."""
return self._metadata.values()
|