-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathextract_string.py
More file actions
32 lines (23 loc) · 782 Bytes
/
Copy pathextract_string.py
File metadata and controls
32 lines (23 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python3
"""Print extracted markdown to stdout (for RAG/LLM pipelines).
Uses default config discovery (DOCPROC_CONFIG, ./docproc.yaml, ~/.config/docproc/docproc.yml).
Set provider API keys per docs/CONFIGURATION.md.
Usage:
python extract_string.py path/to/document.pdf
"""
from __future__ import annotations
import sys
from pathlib import Path
from docproc import Docproc
def main() -> None:
if len(sys.argv) < 2:
print("Usage: python extract_string.py path/to/document.pdf", file=sys.stderr)
sys.exit(1)
inp = Path(sys.argv[1])
if not inp.exists():
print(f"Input not found: {inp}", file=sys.stderr)
sys.exit(1)
md = Docproc.from_env().extract(inp)
print(md, end="")
if __name__ == "__main__":
main()