ISaveContext#

class ISaveContext#

Bases: contextlib.AbstractContextManager, abc.ABC

Defines an abstraction for a save medium.

Overview#

save_file

Save a file to the save medium.

flush

Flush any changes in the context to the underlying stream or file.

close

Close the context.

__exit__

Magic method exit.

Import detail#

from ansys.tools.variableinterop.isave_context import ISaveContext

Method detail#

ISaveContext.__exit__(__exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: types.TracebackType | None) bool | None#

Magic method exit.

abstract ISaveContext.save_file(source: os.PathLike | str, content_id: str | None = None) str#

Save a file to the save medium.

It is up to the ISaveContext implementation to decide how or when to send the actual data. Some ISaveContext implementations may merely collect metadata as part of this call and send the data on flush.

Parameters:
sourceUnion[PathLike, str]

File on disk to send or include in the save.

content_idOptional[str], optional

Unique ID for the file. The default value is None, in which case an ID is automatically generated and returned. This ID can be used with an equivalent ILoadContext instance to load the contents on deserialization.

Returns:
str

ID, either the one provided or the one otherwise generated.

abstract ISaveContext.flush() None#

Flush any changes in the context to the underlying stream or file.

abstract ISaveContext.close() None#

Close the context.