from typing import Any


def encode_h5attr(data: Any) -> Any:
    """Convert a basic data type to something that can be saved as a hdf5 attribute"""
    data_type = type(data).__name__
    try:
        return globals()[f"_{data_type}2h5attr"](data)
    except KeyError:
        return data