PathOps module (overview)¶
PathOps is a rich filesystem toolkit that combines path helpers, directory
queries, transfer utilities, deletions, archive helpers, and data loaders into
one object, It builds on :class:sciwork.fs.base.PathOpsBase, adding features
layer by layer so that high-level workflows can stay anchored to a single
base_dir and share configuration such as dry-run mode or interactive
prompts.
Use the top-level import for the full feature set:
from sciwork import PathOps
fs = PathOps.from_cwd(dry_run=False)
Why PathOps?¶
- Single context - keep a project root in
base_dirand resolve relative paths consistently across helpers likeresolve_pathortransfer. - Dry-run everywhere - flip
dry_run=Trueduring rehearsals to log actions instead of touching the filesystem. - Prompt-aware - interactive operations (delete, selection, prompts) reuse
input_funcorsciwork.console.Prompterwhen available. - Composable mixins - the
PathOpsclass bundles specialized helpers (create, delete, select, archives, data loaders, ...) so you can call them off a single instance.
Module map¶
| Layer | Responsibilities | Methods |
|---|---|---|
Paths |
Resolve/rename paths, prompt for user input, coerce file/folder paths. | coerce_file_path, coerce_folder_path, resolve_path, rename_path, prompt_path |
Dirs |
Validate directories, detect emptiness, wait for new files, temporary folders. | require_dir, try_get_dir, is_folder_empty, wait_until_not_empty, temp_dir |
Create |
Touch files, create folders, ensure parents. | ensure_parent, touch_file, create_file, make_folder |
Delete |
Remove paths or clear folders with optional trash + confirmation. | delete, trash, clear_folder |
Transfer |
Copy or move paths with overwrite and metadata controls. | transfer |
GetContents |
List directory entries with filters and metadata collection. | get_files_and_folders, get_contents |
Select |
Choose one or many entries interactively or programmatically. | select_paths |
Open |
Launch system file explorers/viewers. | open_folder_and_wait |
TreeOps |
Materialise directory trees from adjacency dictionaries. | build_tree |
Archives |
Extract or build ZIP/TAR/RAR archives safely. | extract_archive, compress_to_archive |
Load |
Dispatch data files (CSV, Excel, JSON, ...) to the right loader. | any_data_loader |
fs.names |
Function creating timestamped filename. | create_timestamped_name |
Where to go next¶
- PathOps basics — construct instances, work with
base_diranddry_run, and discover essential helpers. - Recipes — quick, task-oriented examples (create folders, copy trees, select files, extract archives, load data).
- API reference — autogenerated documentation for each class.