diff --git a/docs/source/faq.rst b/docs/source/faq.rst index ca9de96b..6a2f8d7a 100644 --- a/docs/source/faq.rst +++ b/docs/source/faq.rst @@ -85,10 +85,23 @@ Warnings can also be switched off through python's `warnings` package: .. code-block:: python - import warnings - warnings.filterwarnings("ignore") + import warnings + warnings.filterwarnings("ignore") + **My metadata with keys starting with `org_` do not show up in the iBridges metadata.** --------------------------------------------------------------------------------------- -iBridges **does not show** metadata that contain a key starting with the prefix `org_`. This is due to data security reasons on `Yoda systems `__. +By default, iBridges **does not show** metadata that contain a key starting with the prefix `org_`. This is due to data security reasons on `Yoda systems `__. + +You can omit this by the following code: + +.. code-block:: python + + from ibridges.meta import MetaData + + # collections + meta = MetaData(IrodsPath(session, "~", "my_coll").collection, blacklist=None) + # data objects + meta = MetaData(IrodsPath(session, "~", "my_obj").dataobject, blacklist=None) + print(meta) diff --git a/ibridges/meta.py b/ibridges/meta.py index 15c5722b..2873cd32 100644 --- a/ibridges/meta.py +++ b/ibridges/meta.py @@ -58,8 +58,9 @@ def __iter__(self) -> Iterator: """Iterate over all metadata key/value/units triplets.""" if self.blacklist is None: yield from self.item.metadata.items() + return for meta in self.item.metadata.items(): - if re.match(self.blacklist, meta.name) is None: + if self.blacklist and re.match(self.blacklist, meta.name) is None: yield meta else: warnings.warn(f"Ignoring metadata entry with value {meta.name}, because it matches " @@ -148,6 +149,9 @@ def add(self, key: str, value: str, units: Optional[str] = None): try: if (key, value, units) in self: raise ValueError("ADD META: Metadata already present") + if self.blacklist: + if re.match(self.blacklist, key): + raise ValueError(f"ADD META: Key must not start with {self.blacklist}.") self.item.metadata.add(key, value, units) except irods.exception.CAT_NO_ACCESS_PERMISSION as error: raise PermissionError("UPDATE META: no permissions") from error