Run lexgrog on a man page and return the raw synopsis string. Raises FileNotFoundError if the file does not exist, and RuntimeError if lexgrog fails or produces no output.
(gz_path: str, name: str)
| 43 | |
| 44 | |
| 45 | def _run_lexgrog(gz_path: str, name: str) -> str: |
| 46 | """Run lexgrog on a man page and return the raw synopsis string. |
| 47 | |
| 48 | Raises FileNotFoundError if the file does not exist, and RuntimeError |
| 49 | if lexgrog fails or produces no output. |
| 50 | """ |
| 51 | if not os.path.isfile(gz_path): |
| 52 | raise FileNotFoundError(f"manpage file not found: {gz_path}") |
| 53 | proc = subprocess.run( |
| 54 | ["lexgrog", gz_path], capture_output=True, text=True, timeout=300 |
| 55 | ) |
| 56 | if proc.stderr: |
| 57 | logger.warning("lexgrog stderr for %s: %s", name, proc.stderr) |
| 58 | if not proc.stdout or not proc.stdout.strip(): |
| 59 | raise RuntimeError(f"lexgrog produced no output for {gz_path}") |
| 60 | return proc.stdout.rstrip() |
| 61 | |
| 62 | |
| 63 | def get_synopsis_and_aliases(gz_path: str) -> tuple[str | None, list[tuple[str, int]]]: |
no outgoing calls
no test coverage detected