LocalFileValue#

class LocalFileValue(original_path: os.PathLike | None = None, mime_type: str | None = None, encoding: str | None = None, value_id: uuid.UUID | None = None, file_size: int | None = None, actual_content_file_name: os.PathLike | None = None)#

Bases: FileValue, abc.ABC

Base class for file values where the file contents already exist on the local disk.

Overview#

get_reference_to_actual_content_file_async

Realize the file contents to a local filesystem if needed.

get_reference_to_actual_content_file

Realizes the file contents to a local filesystem if needed.

actual_content_file_name

Get the path to the file that this FileValue instance wraps.

Import detail#

from ansys.tools.variableinterop.file_value import LocalFileValue

Property detail#

property LocalFileValue.actual_content_file_name: os.PathLike | None#

Get the path to the file that this FileValue instance wraps.

Returns:
Optional[PathLike]

PathLike to the file.

Method detail#

async LocalFileValue.get_reference_to_actual_content_file_async(progress_callback: Callable[[int], None] | None = None) AsyncLocalFileContentContext#

Realize the file contents to a local filesystem if needed.

The FileValue instance is intended to represent an immutable value. The file returned by this call may point to a cached file or even the original file. Callers must not modify the file on disk. Otherwise, undefined behaviors, including class 3 errors, may occur. If the caller needs to modify the file, consider using the write_file method or copying the file before modifying it.

Parameters:
progress_callbackOptional[Callable[[int], None]], optional

Callback that can be called to indicate progress in realizing the local copy. The default is None, in which case this method makes no attempt to report its progress. This method may call a provided callback with a percentage value between 0 and 100 inclusive. The provided callback may not necessarily be called at all, and calls for 0 or 100 percent are not guaranteed, even if other calls occur.

Returns:
AsyncLocalFileContentContext

Context manager that, when exited, deletes the local copy if it is a temporary file.

LocalFileValue.get_reference_to_actual_content_file(progress_callback: Callable[[int], None] | None = None) LocalFileContentContext#

Realizes the file contents to a local filesystem if needed.

The FileValue instance is intended to represent an immutable value. The file returned by this call may point to a cached file or even the original file. Callers must not modify the file on disk. Otherwise, undefined behaviors, including class 3 errors, may occur. If the caller needs to modify the file, consider using the write_file method or copying the file before modifying it.

Parameters:
progress_callbackOptional[Callable[[int], None]], optional

Callback that can be called to indicate progress in realizing the local copy. The default is None, in which case this method makes no attempt to report its progress. This method may call a provided callback with a percentage value between 0 and 100 inclusive. The provided callback may not necessarily be called at all, and calls for 0 or 100 percent are not guaranteed, even if other calls occur.

Returns:
LocalFileContentContext

Context manager that, when exited, deletes the local copy if it is a temporary file.