"""Function to load logs from files."""from__future__importannotationsimportosfromdatalogs._logsimportDataLog,DictLog
[docs]defload_log(path:str)->DataLog|DictLog:""" Load the log specified by the given file path. If the extension is ".nc" (NetCDF), a :py:class:`DataLog` containing an Xarray ``Dataset`` will be loaded. If the extension is ".json" (JSON), a :py:class:`DictLog` containing a dictionary will be loaded. """ext=os.path.splitext(path)[1].lower()log_type:type[DataLog|DictLog]ifext==".nc":log_type=DataLogelifext==".json":log_type=DictLogelse:raiseValueError(f"'{ext}' file extension is not supported")returnlog_type.load(path)