snowflake.hypothesis_snowpark.io_utils.EnvStrategy¶
- class snowflake.hypothesis_snowpark.io_utils.EnvStrategy¶
Bases:
ABC
An abstract base class that defines methods for file and directory operations.
Subclasses should implement these methods to provide environment-specific behavior.
Methods
- abstractmethod file_exists(path: str) bool ¶
Check if a file exists.
- Parameters:
path – The path to the file.
- Returns:
True if the file exists, False otherwise.
- Return type:
bool
- abstractmethod folder_exists(path: str) bool ¶
Check if a folder exists.
- Parameters:
path – The path to the folder.
- Returns:
True if the folder exists, False otherwise.
- Return type:
bool
- abstractmethod getcwd() str ¶
Get the current working directory.
- Returns:
The current working directory.
- Return type:
str
- abstractmethod ls(path: str, recursive: bool = False) list[str] ¶
List the contents of a directory.
- Parameters:
path – The path to the directory.
recursive – If True, list the contents recursively.
- Returns:
A list of the contents of the directory.
- Return type:
list[str]
- abstractmethod mkdir(path: str, exist_ok: bool = False) None ¶
Create a directory.
- Parameters:
path – The name of the directory to create.
exist_ok – If False, an error is raised if the directory already exists.
- abstractmethod read(file_path: str, mode: str = 'r', encoding: str | None = None) str ¶
Read content from a file.
- Parameters:
file_path – The path to the file to read from.
mode – The mode in which to open the file.
encoding – The encoding to use for reading the file.
- Returns:
The content of the file.
- Return type:
str
- abstractmethod read_bytes(file_path: str) bytes ¶
Read binary content from a file.
- Parameters:
file_path – The path to the file to read from.
- Returns:
The binary content of the file.
- Return type:
bytes
- abstractmethod telemetry_path_files(path: str) Path ¶
Get the path to the telemetry files.
- Parameters:
path – The path to the telemetry directory.
- Returns:
The path object representing the telemetry files.
- Return type:
Path
- abstractmethod write(file_path: str, file_content: str, overwrite: bool = True) None ¶
Write content to a file.
- Parameters:
file_path – The name of the file to write to.
file_content – The content to write to the file.
overwrite – If True, overwrite the file if it exists.