openclean.data.store.fs module

Implementation for the object store interface that maintains all objects as serialized Json documents in files on the file system.

class openclean.data.store.fs.FileSystemJsonStore(basedir: str, encoder: Optional[json.encoder.JSONEncoder] = None, decoder: Optional[Callable] = None)

Bases: openclean.data.store.base.DataStore

Data store that maintains all objects as Json files in a directory on the file system.

delete_object(object_id: str) bool

Remove the file for the object with the given identifier. Raises a KeyError if the object identifier is unknown, i.e., if the object file does not exist.

Parameters

object_id (string) – Unique object identifier.

Raises

KeyError

read_object(object_id: str) Any

Get the serialized object that is identified by the given object id. Raises a KeyError if the referenced object does not exist.

Parameters

object_id (string) – Unique object identifier.

Return type

any

Raises

KeyError

write_object(object: Any, object_id: Optional[str] = None) str

Store an object in the repository. If the object identifier is given an existing file for that identifier will be overwritten. Returns the unique object identifier.

Parameters
  • object (any) – Serialization for an object.

  • object_id (str, default=None) – Optional identifier for the stored object. If not given, a unique identifier will be generated.

Return type

string