Skip to content

metadata¤

Provides information about data.

Metadata ¤

Metadata(*, read_only, node_name, **kwargs)

Bases: FreezableMap[Any]

Provides information about data.

Warning

Do not instantiate directly. A Metadata object is created automatically when create_dataset or create_group is called.

Parameters:

Name Type Description Default
read_only bool

Whether Metadata is initialised in read-only mode.

required
node_name str

The name of the node that the Metadata is associated with.

required
kwargs Any

All other keyword arguments are used to create the mapping.

{}
Source code in src/msl/io/metadata.py
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
def __init__(self, *, read_only: bool, node_name: str, **kwargs: Any) -> None:
    """Provides information about data.

    !!! warning
        Do not instantiate directly. A [Metadata][msl.io.metadata.Metadata] object is created automatically
        when [create_dataset][msl.io.node.Group.create_dataset] or
        [create_group][msl.io.node.Group.create_group] is called.

    Args:
        read_only: Whether [Metadata][msl.io.metadata.Metadata] is initialised in read-only mode.
        node_name: The name of the node that the [Metadata][msl.io.metadata.Metadata] is associated with.
        kwargs: All other keyword arguments are used to create the mapping.
    """
    meta = {k: _value(value=v, read_only=read_only, name=node_name) for k, v in kwargs.items()}
    super().__init__(read_only=read_only, **meta)
    self._node_name: str = node_name

read_only property writable ¤

read_only

bool — Whether the map is in read-only mode.

clear ¤

clear()

Maybe remove all items from the map, only if the map is not in read-only mode.

Source code in src/msl/io/freezable.py
58
59
60
61
def clear(self) -> None:
    """Maybe remove all items from the map, only if the map is not in read-only mode."""
    self._raise_if_read_only()
    self._mapping.clear()

copy ¤

copy(*, read_only=None)

Create a copy of the Metadata.

Parameters:

Name Type Description Default
read_only bool | None

Whether the copy should be created in read-only mode. If None, creates a copy using the mode for the Metadata object that is being copied.

None

Returns:

Type Description
Metadata

A copy of the Metadata.

Source code in src/msl/io/metadata.py
145
146
147
148
149
150
151
152
153
154
155
156
157
def copy(self, *, read_only: bool | None = None) -> Metadata:
    """Create a copy of the [Metadata][msl.io.metadata.Metadata].

    Args:
        read_only: Whether the copy should be created in read-only mode.
            If `None`, creates a copy using the mode for the [Metadata][msl.io.metadata.Metadata]
            object that is being copied.

    Returns:
        A copy of the [Metadata][msl.io.metadata.Metadata].
    """
    ro = self._read_only if read_only is None else read_only
    return Metadata(read_only=ro, node_name=self._node_name, **self._mapping)

fromkeys ¤

fromkeys(seq, value=None, *, read_only=None)

Create a new Metadata object with keys from seq and values set to value.

Parameters:

Name Type Description Default
seq Iterable[str]

Any iterable object that contains the names of the keys.

required
value Any

The default value to use for each key.

None
read_only bool | None

Whether the returned Metadata object should be initialised in read-only mode. If None, uses the mode for the Metadata that is used to call this method.

None

Returns:

Type Description
Metadata

A new Metadata object.

Source code in src/msl/io/metadata.py
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
def fromkeys(self, seq: Iterable[str], value: Any = None, *, read_only: bool | None = None) -> Metadata:
    """Create a new [Metadata][msl.io.metadata.Metadata] object with keys from `seq` and values set to `value`.

    Args:
        seq: Any iterable object that contains the names of the keys.
        value: The default value to use for each key.
        read_only: Whether the returned [Metadata][msl.io.metadata.Metadata] object should be initialised in
            read-only mode. If `None`, uses the mode for the [Metadata][msl.io.metadata.Metadata] that is used
            to call this method.

    Returns:
        A new [Metadata][msl.io.metadata.Metadata] object.
    """
    ro = self._read_only if read_only is None else read_only
    return Metadata(read_only=ro, node_name=self._node_name, **dict.fromkeys(seq, value))

items ¤

items()

ItemsView[str, VT] — Return a view of the map's items.

Source code in src/msl/io/freezable.py
71
72
73
def items(self) -> ItemsView[str, VT]:
    """[ItemsView][collections.abc.ItemsView][[str][], VT] — Return a view of the map's items."""
    return ItemsView(self)

keys ¤

keys()

KeysView[str] — Returns a view of the map's keys.

Source code in src/msl/io/freezable.py
63
64
65
def keys(self) -> KeysView[str]:
    """[KeysView][collections.abc.KeysView][[str][]] — Returns a view of the map's keys."""
    return KeysView(self)

values ¤

values()

ValuesView[VT] — Returns a view of the map's values.

Source code in src/msl/io/freezable.py
67
68
69
def values(self) -> ValuesView[VT]:
    """[ValuesView][collections.abc.ValuesView][VT] — Returns a view of the map's values."""
    return ValuesView(self)