Skip to content
Snippets Groups Projects
Commit 395e5ef0 authored by Vincent POLLET's avatar Vincent POLLET
Browse files

Implement few utility methods for metadata classes.

parent 14d3b0c2
No related branches found
No related tags found
1 merge request!22Draft: Implements metadata handling for bob.io.stream.Stream and bob.io.stream.StreamFile
...@@ -78,6 +78,8 @@ class MetaDatum: ...@@ -78,6 +78,8 @@ class MetaDatum:
# type using the numpy item. # type using the numpy item.
elif isinstance(value, np.generic): elif isinstance(value, np.generic):
self.set(value.item()) self.set(value.item())
elif value is None or self.value is None:
pass # allow to set to None whichever the type of the Metadatum is.
else: else:
raise TypeError( raise TypeError(
"Metadatum " "Metadatum "
...@@ -212,6 +214,16 @@ class MetaData: ...@@ -212,6 +214,16 @@ class MetaData:
""" """
return self.__dict.__contains__(item) return self.__dict.__contains__(item)
def __bool__(self):
"""Return True if the metadata collection is empty.
Returns
-------
bool
True if there are no metadatum in the metadata, False otherwise.
"""
return bool(self.__dict)
def keys(self): def keys(self):
"""Return an iterable on the collection's metadatum names.""" """Return an iterable on the collection's metadatum names."""
return self.__dict.keys() return self.__dict.keys()
...@@ -246,7 +258,7 @@ class MetaDataInfo: ...@@ -246,7 +258,7 @@ class MetaDataInfo:
.. note:: .. note::
:class:`bob.io.stream.Stream` uses the property names `"herited"` and `"per_frame"` to determine how to access :class:`bob.io.stream.Stream` uses the property names `"herited"` and `"per_frame"` to determine how to access
the metadata. the metadata. `"no_write"` and `"must_write"` are also used to override the default metadata writing behavior.
""" """
def __init__(self, info_dict=None): def __init__(self, info_dict=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment