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.

Parameters:

path (Path) – The directory path to create.

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

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

Parameters:

path (Path) – The path to check.

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.

Parameters:

path (Path) – The path to check.

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.

Parameters:

path (Union[Path, str]) – The path to the file.

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.

Parameters:
  • path (Path) – The path to the file.

  • data (bytes) – The content to write to the file.