photon_platform.clerk.fs¶
Safe, structured filesystem operations for Clerk (Ranger-parity file ops).
Classes¶
Structured result for any Clerk filesystem operation. |
|
One file discovered by |
Functions¶
|
Rename a file or directory within its parent directory. |
|
Copy one or more files/directories into |
|
Move one or more files/directories into |
|
Create a directory (or nested relative path) under |
|
Create a new file under |
|
Safely send paths to the desktop trash via |
|
Recursively flatten files under |
Module Contents¶
- class photon_platform.clerk.fs.FsResult¶
Structured result for any Clerk filesystem operation.
- class photon_platform.clerk.fs.FlatEntry¶
One file discovered by
flatten_tree().- path: pathlib.Path¶
- photon_platform.clerk.fs.rename_path(src: pathlib.Path | str, new_name: str, *, overwrite: bool = False, dry_run: bool = False) FsResult¶
Rename a file or directory within its parent directory.
- Parameters:
src – Source path to rename.
new_name – New basename (must not contain path separators).
overwrite – Allow replacing an existing destination.
dry_run – Plan the rename without mutating the filesystem.
- Returns:
Structured
FsResult.
- photon_platform.clerk.fs.copy_paths(sources: collections.abc.Sequence[pathlib.Path | str], dest_dir: pathlib.Path | str, *, overwrite: bool = False, dry_run: bool = False) FsResult¶
Copy one or more files/directories into
dest_dir.- Parameters:
sources – Paths to copy.
dest_dir – Target destination directory.
overwrite – Allow overwriting existing entries in
dest_dir.dry_run – Plan without copying.
- Returns:
Structured
FsResult.
- photon_platform.clerk.fs.move_paths(sources: collections.abc.Sequence[pathlib.Path | str], dest_dir: pathlib.Path | str, *, overwrite: bool = False, dry_run: bool = False) FsResult¶
Move one or more files/directories into
dest_dir.- Parameters:
sources – Paths to move.
dest_dir – Target destination directory.
overwrite – Allow replacing existing destinations.
dry_run – Plan without moving.
- Returns:
Structured
FsResult.
- photon_platform.clerk.fs.create_dir(parent: pathlib.Path | str, name: str, *, dry_run: bool = False) FsResult¶
Create a directory (or nested relative path) under
parent.
- photon_platform.clerk.fs.create_file(parent: pathlib.Path | str, name: str, *, content: str = '', overwrite: bool = False, dry_run: bool = False) FsResult¶
Create a new file under
parent.
- photon_platform.clerk.fs.trash_paths(sources: collections.abc.Sequence[pathlib.Path | str], *, dry_run: bool = False, trash_cmd: collections.abc.Sequence[str] | None = None) FsResult¶
Safely send paths to the desktop trash via
gio trash(neverrm -rf).- Parameters:
sources – Paths to trash.
dry_run – Preview which paths would be trashed without modifying disk.
trash_cmd – Optional command override (defaults to
("gio", "trash")).
- Returns:
Structured
FsResult.
- photon_platform.clerk.fs.flatten_tree(root: pathlib.Path | str, *, include_hidden: bool = False, max_depth: int | None = None, ignore_dirs: frozenset[str] = DEFAULT_IGNORE_DIRS, limit: int | None = None) list[FlatEntry]¶
Recursively flatten files under
root(Rangerz_/flat -1parity).- Parameters:
root – Directory to flatten.
include_hidden – Include dot-prefixed entries when true.
max_depth – Optional maximum directory depth (
1= immediate children).ignore_dirs – Directory names pruned during traversal.
limit – Optional cap on returned entries.
- Returns:
Naturally sorted list of
FlatEntryobjects.