context package¶
context module¶
-
class
mindreader.drivers.context.context.Context(path: str, is_file=False)¶ Bases:
objectThis class is used to communicate with the storage (i.e. save/load files).
-
default_base_dir= PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/mindreader/checkouts/latest/mindreader_internal_data')¶ This is the default directory which files are saved into, when creating a context object
-
classmethod
generate_context_from_snapshot_metadata(metadata: mindreader.objects.snapshot_utils.SnapshotMetadata, base_dir='')¶ Generate a context that is based on snapshot metadata.
- Parameters
metadata – a snapshot metadata.
base_dir – a base directory, which the context directory will be created under.
-
get_file_path(name)¶ Return the full path of a file in the context directory. Its on the caller responsibility to validate the existence of the path/file if needed.
- Parameters
name – name of the file, in the context directory.
-
load(name, byte=False, is_json=False)¶ Loads file from storage.
- Parameters
name – name of the file, in the context directory.
byte – should be set to True if the data to be loaded is in bytes format.
is_json – should be set to True if the data to be loaded is in JSON format.
-
save(name: str, data, is_json=False)¶ Saves data to storage.
- Parameters
name – name of the saved file.
data – the data to save. should be in a format that can be saved.
is_json – should be True if data is in JSON format (not already dumped).
-