(record: dict)
| 50 | |
| 51 | |
| 52 | def pdf_source_candidates(record: dict) -> list[tuple[str, str]]: |
| 53 | candidates: list[tuple[str, str]] = [] |
| 54 | local_pdf = str(record.get("local_pdf_path", "")).strip() |
| 55 | if local_pdf and Path(local_pdf).expanduser().exists(): |
| 56 | return [("local_pdf", str(Path(local_pdf).expanduser().resolve()))] |
| 57 | |
| 58 | pdf_url = str(record.get("pdf_url", "")).strip() |
| 59 | if pdf_url: |
| 60 | append_candidate(candidates, "pdf_url", pdf_url) |
| 61 | |
| 62 | source_url = str(record.get("source_url", "")).strip() |
| 63 | if source_url.lower().endswith(".pdf"): |
| 64 | append_candidate(candidates, "pdf_url", source_url) |
| 65 | |
| 66 | arxiv_id = str(record.get("arxiv_id", "")).strip() |
| 67 | if arxiv_id: |
| 68 | append_candidate(candidates, "pdf_url", f"https://arxiv.org/pdf/{arxiv_id}.pdf") |
| 69 | |
| 70 | doi = extract_doi(str(record.get("doi", "")).strip()) |
| 71 | if doi: |
| 72 | enriched = enrich_metadata({"doi": doi, "title": record.get("title", "")}) |
| 73 | enriched_pdf = str(enriched.get("pdf_url", "")).strip() |
| 74 | if enriched_pdf: |
| 75 | append_candidate(candidates, "pdf_url", enriched_pdf) |
| 76 | frontiers_pdf = frontiers_pdf_url_from_doi(doi) |
| 77 | if frontiers_pdf: |
| 78 | append_candidate(candidates, "pdf_url", frontiers_pdf) |
| 79 | |
| 80 | return candidates |
| 81 | |
| 82 | |
| 83 | def main(argv: list[str] | None = None) -> None: |
no test coverage detected