hydra.overlay.python.lib.files module
Python implementations of hydra.overlay.python.lib.files primitives.
These are real file-system primitives. In Python the Hydra type effect<t> is
transparent (effect<t> = t), so each primitive performs its I/O eagerly and returns
an Either[FileError, T]: a recoverable file-system failure is returned as
Left(error); success is returned as Right(value). This mirrors the Haskell
reference implementation in Hydra.Haskell.Lib.Files, including the classify mapping
of OS errors to FileError variants. For #494.
- hydra.overlay.python.lib.files.append_file(path: FilePath, contents: bytes) object
Append raw bytes to the end of a file, creating it if it does not exist.
- hydra.overlay.python.lib.files.copy(recursive: bool, source: FilePath, destination: FilePath) object
Copy source to destination. If recursive, source may be a directory whose tree is copied.
- hydra.overlay.python.lib.files.create_directory(recursive: bool, path: FilePath) object
Create a directory. If recursive, create any missing parent directories as well.
- hydra.overlay.python.lib.files.create_symlink(target: FilePath, link: FilePath) object
Create a symbolic link at link, pointing to target. Fails if link already exists.
- hydra.overlay.python.lib.files.exists(path: FilePath) object
Test whether anything exists at the given path.
- hydra.overlay.python.lib.files.list_directory(path: FilePath) object
List the bare entry names of a directory (not full paths), mirroring Haskell listDirectory.
- hydra.overlay.python.lib.files.read_file(path: FilePath) object
Read the entire contents of a file as raw bytes.
- hydra.overlay.python.lib.files.read_symlink(path: FilePath) object
Read the target of the symbolic link at path, verbatim and unresolved.
- hydra.overlay.python.lib.files.remove_directory(recursive: bool, path: FilePath) object
Remove a directory. If recursive, remove its entire contents; otherwise it must be empty.
- hydra.overlay.python.lib.files.rename(source: FilePath, destination: FilePath) object
Rename (move) a file or directory from source to destination.
- hydra.overlay.python.lib.files.status(follow_links: bool, path: FilePath) object
Retrieve metadata about the file at path. When follow_links is true, this is POSIX stat: a symbolic link’s metadata is that of its target, and a dangling link is not found. When follow_links is false, this is POSIX lstat: a symbolic link’s own metadata is reported, with file_type LINK, never an error for a dangling link.