(doc_token: Optional[str])
| 4312 | |
| 4313 | def _resolve_doc_url_from_meta(doc_token: Optional[str]) -> Optional[str]: |
| 4314 | if not doc_token or not callable(get_drive_meta): |
| 4315 | return None |
| 4316 | |
| 4317 | try: |
| 4318 | meta = get_drive_meta(doc_token) |
| 4319 | except Exception as exc: |
| 4320 | print(f"Unable to fetch drive meta for doc {doc_token}: {exc}") |
| 4321 | return None |
| 4322 | |
| 4323 | if not isinstance(meta, dict): |
| 4324 | return None |
| 4325 | |
| 4326 | candidates = [meta.get("url"), meta.get("doc_url")] |
| 4327 | data = meta.get("data") |
| 4328 | if isinstance(data, dict): |
| 4329 | candidates.extend([data.get("url"), data.get("doc_url")]) |
| 4330 | metas = data.get("metas") |
| 4331 | if isinstance(metas, list): |
| 4332 | for item in metas: |
| 4333 | if isinstance(item, dict): |
| 4334 | candidates.extend([item.get("url"), item.get("doc_url")]) |
| 4335 | |
| 4336 | for candidate in candidates: |
| 4337 | text = str(candidate or "").strip() |
| 4338 | if text.startswith("http://") or text.startswith("https://"): |
| 4339 | return text |
| 4340 | return None |
| 4341 | |
| 4342 | |
| 4343 | def _normalize_report_style(value: Any) -> str: |
| 4344 | style = _clean_text(value).lower() |
no test coverage detected