get_format

function of dascore.io.core source

get_format(
    path: str | pathlib.Path | dascore.utils.io.IOResourceManager[str, Path, IOResourceManager] ,
    file_format: str | None[str, None] = None,
    file_version: str | None[str, None] = None,
    fiber_io_hint: dict[dict[str, FiberIO], None] = None,
    **kwargs ,
)-> ‘tuple[str, str]’

Return the name of the format contained in the file and version number.

Parameters

Parameter Description
path The path to the file.
file_format The known file format.
file_version The known file version.
fiber_io_hint A dict of {input_type: fiber_io}. This is an optimization
which assumes the last used fiberio (for a given input type)
is likely to be the next one.

Returns

A tuple of (file_format_name, version) both as strings.

Raises

dascore.exceptions.UnknownFiberFormat - Could not determine the fiber format.

Examples

import dascore as dc
from dascore.utils.downloader import fetch

file_path = fetch("prodml_2.1.h5")

file_format, file_version = dc.get_format(file_path)