Skip to content

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_dir and resolve relative paths consistently across helpers like resolve_path or transfer.
  • Dry-run everywhere - flip dry_run=True during rehearsals to log actions instead of touching the filesystem.
  • Prompt-aware - interactive operations (delete, selection, prompts) reuse input_func or sciwork.console.Prompter when available.
  • Composable mixins - the PathOps class 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_dir and dry_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.