mwdblib icon indicating copy to clipboard operation
mwdblib copied to clipboard

More useful access to attributes

Open psrok1 opened this issue 2 years ago • 0 comments

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

psrok1 avatar Jun 23 '22 10:06 psrok1