MCPcopy Create free account
hub / github.com/917Dhj/DeepPaperNote / pdf_source_candidates

Function pdf_source_candidates

scripts/fetch_pdf.py:52–80  ·  view source on GitHub ↗
(record: dict)

Source from the content-addressed store, hash-verified

50
51
52def 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
83def main(argv: list[str] | None = None) -> None:

Callers 2

choose_pdf_sourceFunction · 0.85
mainFunction · 0.85

Calls 4

extract_doiFunction · 0.90
enrich_metadataFunction · 0.90
append_candidateFunction · 0.85

Tested by

no test coverage detected