pyrit.models.DiskStorageIO#

class DiskStorageIO[source]#

Bases: StorageIO

Implementation of StorageIO for local disk storage.

__init__()#

Methods

__init__()

create_directory_if_not_exists(path)

Asynchronously creates a directory if it doesn't exist on the local disk.

is_file(path)

Checks if the given path is a file (not a directory).

path_exists(path)

Checks if a path exists on the local disk.

read_file(path)

Asynchronously reads a file from the local disk.

write_file(path, data)

Asynchronously writes data to a file on the local disk.

async create_directory_if_not_exists(path: Path | str) None[source]#

Asynchronously creates a directory if it doesn’t exist on the local disk. :param path: The directory path to create. :type path: Path

async is_file(path: Path | str) bool[source]#

Checks if the given path is a file (not a directory). :param path: The path to check. :type path: Path

Returns:

True if the path is a file, False otherwise.

Return type:

bool

async path_exists(path: Path | str) bool[source]#

Checks if a path exists on the local disk. :param path: The path to check. :type path: Path

Returns:

True if the path exists, False otherwise.

Return type:

bool

async read_file(path: Path | str) bytes[source]#

Asynchronously reads a file from the local disk. :param path: The path to the file. :type path: Union[Path, str]

Returns:

The content of the file.

Return type:

bytes

async write_file(path: Path | str, data: bytes) None[source]#

Asynchronously writes data to a file on the local disk. :param path: The path to the file. :type path: Path :param data: The content to write to the file. :type data: bytes