pdf-tools/src/pdf_tools/common.py
Eric Furst e464871b69 Initial public release of pdf-tools
Command-line tools for marked-up PDFs and scanned handwritten notes:
pdf-scrub, pdf-notes-md, scan-notes-md (Ollama by default, Claude on
request), scan-notes-index (per-page search metadata), and
scan-notes-stats.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011ZSvbNaLhgFuTm7wmkgbWs
2026-11-03 07:25:51 -05:00

21 lines
467 B
Python

"""Shared helpers across the three tools."""
from __future__ import annotations
import sys
from pathlib import Path
def err(msg: str) -> None:
print(msg, file=sys.stderr)
def must_exist(p: Path) -> Path:
if not p.exists():
err(f"error: not found: {p}")
sys.exit(2)
return p
def with_suffix_before_ext(p: Path, marker: str) -> Path:
"""foo.pdf + '_clean' -> foo_clean.pdf"""
return p.with_name(f"{p.stem}{marker}{p.suffix}")