try: if sys.platform.startswith("darwin"): # macOS os.system(f'open "path"') elif sys.platform.startswith("win"): # Windows os.startfile(str(path)) # type: ignore[arg-type] # noqa: S607 else: # Linux / other *nix os.system(f'xdg-open "path"') except Exception as e: # Not fatal – we just inform the user print(f"⚠️ Could not open the PDF automatically: e", file=sys.stderr)
# ------------------------------------------------------------------ # Public API # ------------------------------------------------------------------
save_folder: Destination directory for the PDF. Will be created automatically.
# 4️⃣ Optional open -------------------------------------------------- def _open_file(self, path: pathlib.Path) -> None: """ Cross‑platform helper that launches the default PDF viewer. """ if not path.is_file(): raise FileNotFoundError(f"Cannot open non‑existent file: path")
import os import pathlib import sys import time import urllib.parse from dataclasses import dataclass from typing import Iterable, List, Optional, Tuple, Union
# Internal state (filled later) self._pdf_path: pathlib.Path | None = None