Write a parsed document to storage. Returns the assigned record ID.
(doc: dict)
| 30 | |
| 31 | |
| 32 | def save_parsed(doc: dict) -> str: |
| 33 | """Write a parsed document to storage. Returns the assigned record ID.""" |
| 34 | _ensure_storage() |
| 35 | record_id = str(uuid.uuid4())[:8] |
| 36 | path = STORAGE_DIR / f"{record_id}.json" |
| 37 | path.write_text(json.dumps(doc, indent=2)) |
| 38 | |
| 39 | index = load_index() |
| 40 | index[record_id] = { |
| 41 | "source": doc.get("source", ""), |
| 42 | "format": doc.get("format", ""), |
| 43 | "title": doc.get("title", ""), |
| 44 | } |
| 45 | save_index(index) |
| 46 | return record_id |
| 47 | |
| 48 | |
| 49 | def save_processed(doc: dict) -> str: |
no test coverage detected