adsfolio.pdf.identify

Cached PDF identification workflow.

class adsfolio.pdf.identify.IdentifyWorkflowHelpers(parallel_map_paths, to_sidecar_key, format_elapsed, profile_sync_payload, estimate_ads_queries_for_targets, should_prompt_ads_permission, confirm_ads_queries, progress_reporter_factory, build_progress, parallel_extract_first_page_previews, write_unresolved_csv, print_unresolved_ai_prompt, resolve_from_ai_csv, ads_block_risk_threshold)[source]

Bases: object

Callbacks retained by the PDF CLI while its commands share them.

Parameters:
ads_block_risk_threshold: int
build_progress: collections.abc.Callable[[...], Any | None]
confirm_ads_queries: collections.abc.Callable[[...], tuple[str, int]]
estimate_ads_queries_for_targets: collections.abc.Callable[[...], dict[str, Any]]
format_elapsed: collections.abc.Callable[[float], str]
parallel_extract_first_page_previews: collections.abc.Callable[[...], dict[pathlib.Path, str]]
parallel_map_paths: collections.abc.Callable[[...], dict[pathlib.Path, Any]]
print_unresolved_ai_prompt: collections.abc.Callable[[pathlib.Path], None]
profile_sync_payload: collections.abc.Callable[[Any], dict[str, Any]]
progress_reporter_factory: collections.abc.Callable[[], Any]
resolve_from_ai_csv: collections.abc.Callable[[...], dict[pathlib.Path, dict[str, Any]]]
should_prompt_ads_permission: collections.abc.Callable[[], bool]
to_sidecar_key: collections.abc.Callable[[pathlib.Path, pathlib.Path], str]
write_unresolved_csv: collections.abc.Callable[[...], pathlib.Path | None]
adsfolio.pdf.identify.build_cached_candidate_lookup(identifier, registry, documents)[source]

Build a unique cached-document lookup for every strategy candidate kind.

Parameters:
Return type:

collections.abc.Callable[[str, Any], tuple[bool, dict[str, Any] | None]]

adsfolio.pdf.identify.build_checked_record(identifier, document, path, sha256)[source]

Build a record, or note why the PDF does not prove document.

Parameters:
Return type:

dict[str, Any] | None

adsfolio.pdf.identify.cached_ads_record(registry, identifier, path, doi='', bibcode='', sha256='')[source]

Return cache-hit status and a unique folder-cache identify record.

A cached document that the PDF does not prove is reported as a cache hit without a record, and the reason is kept in identifier.identity_failures.

Parameters:
Return type:

tuple[bool, dict[str, Any] | None]

adsfolio.pdf.identify.print_cache_status(cached)[source]

Print cache age and document count for an identify run.

Parameters:

cached (adsfolio.pubcache.CachedPublications | None)

Return type:

None

adsfolio.pdf.identify.run_identify(client, directory, *, helpers, recursive, debut_year, end_year, refresh_cache, output_unresolved, skip_unresolved_directory, apply, verbose_parser, strategies, allow_ads, ai_csv, verbose, profile=None, prompt_for_ai_csv=True, providers=(DoiProvider.ADS, DoiProvider.CROSSREF, DoiProvider.DATACITE), paths=None)[source]

Identify PDFs and persist their ADS metadata.

paths, when given, are the PDFs to identify in place of a scan of directory. They must lie inside directory. The unresolved directory is not skipped for them, because the user chose them.

Parameters:
Return type:

None