Best-effort extract the document token from different Feishu response shapes.
(doc_info: Dict[str, Any])
| 486 | |
| 487 | |
| 488 | def extract_doc_token(doc_info: Dict[str, Any]) -> Optional[str]: |
| 489 | """Best-effort extract the document token from different Feishu response shapes.""" |
| 490 | if not isinstance(doc_info, dict): |
| 491 | return None |
| 492 | |
| 493 | for candidate in (doc_info.get("obj_token"), doc_info.get("document_id"), doc_info.get("token")): |
| 494 | if isinstance(candidate, str) and candidate.strip(): |
| 495 | return candidate.strip() |
| 496 | |
| 497 | data = doc_info.get("data") |
| 498 | if isinstance(data, dict): |
| 499 | for candidate in (data.get("obj_token"), data.get("document_id"), data.get("token")): |
| 500 | if isinstance(candidate, str) and candidate.strip(): |
| 501 | return candidate.strip() |
| 502 | |
| 503 | document = data.get("document") |
| 504 | if isinstance(document, dict): |
| 505 | for candidate in ( |
| 506 | document.get("obj_token"), |
| 507 | document.get("document_id"), |
| 508 | document.get("token"), |
| 509 | ): |
| 510 | if isinstance(candidate, str) and candidate.strip(): |
| 511 | return candidate.strip() |
| 512 | |
| 513 | return None |
| 514 | |
| 515 | |
| 516 | def _load_arxiv_fetcher(): |
no test coverage detected