mwdblib
mwdblib copied to clipboard
More useful access to attributes
One of use-cases found during some code review:
def remove_attribute(sample: mwdblib.MWDBFile, key: str, value: Any = None) -> None:
for attribute in sample.attributes[key]:
if value is None or attribute.value == value:
sample.remove_attribute(attribute.id)
Code above is wrong but shows expected usage of new API.
get_attributes_detailed
exposes identifiers, but attributes are not grouped by key. In addition, it would be nice to have them in named tuples (accessible by getattr, .value
) instead of regular dicts with ["value"]
syntax to access the value