[docs]defread_object(path:str,metadata:Optional[dict]=None,**kwargs)->Any:""" Read an object from its on-disk representation. This will dispatch to individual reading functions - possibly from different packages in the **dolomite** framework based on the ``metadata`` from the ``OBJECT`` file. Application developers can control the dispatch process by modifying ``read_object_registry``. Each key is a string containing the object type, e.g., ``data_frame``, while the value can either be a string specifying the fully qualified name of a reader function (including all modules, which will be loaded upon dispatch) or the reader function itself. Any reader functions should accept the same arguments as :py:func`~dolomite_base.read-object.read_object` and return the loaded object. Readers may assume that the ``metadata`` argument is available, i.e., no need to account for the None case. Args: path: Path to a directory containing the object. metadata: Metadata for the object. If None, the metadata is read from the ``OBJECT`` file inside ``path``. kwargs: Further arguments, passed to individual methods. Returns: Some kind of object. """ifmetadataisNone:metadata=read_object_file(path)tt=metadata["type"]ifttnotinread_object_registry:raiseNotImplementedError("could not find a Python function to read '"+tt+"'")command=read_object_registry[tt]ifisinstance(command,str):first_period=command.find(".")mod_name=command[:first_period]try:mod=import_module(mod_name)except:raiseModuleNotFoundError("no module named '"+mod_name+"' for reading an instance of '"+tt+"'")command=getattr(mod,command[first_period+1:])read_object_registry[tt]=commandreturncommand(path,metadata,**kwargs)