adsfolio.library_sync
Qt-free local selection and ADS library synchronization helpers.
- class adsfolio.library_sync.AddDocumentsResult(acknowledged=(), already_present=(), failed=(), status_unknown=(), unattempted=(), cancelled=False, error=None)[source]
Bases:
objectStructured outcome for preflight or batched document additions.
- Parameters:
- class adsfolio.library_sync.AdsLibraryService(client)[source]
Bases:
objectCoordinate local Bibcodes with the ADS libraries API.
- Parameters:
client (ADSClient)
- MAX_DOCUMENTS_PER_REQUEST = 2000
- add_documents(library_id, bibcodes, *, already_present=(), cancelled=<function AdsLibraryService.<lambda>>)[source]
Add Bibcodes in bounded sequential requests.
- Parameters:
library_id (str) – Destination ADS library identifier.
bibcodes (sequence of str) – Bibcodes to add, normalized and deduplicated in source order.
already_present (sequence of str, optional) – Bibcodes known to be in the destination already.
cancelled (callable, optional) – Predicate checked before every add request.
- Returns:
Structured partial outcome for the operation.
- Return type:
- Raises:
PermissionError – If a listed destination is not writable.
- create_destination(name, description, public)[source]
Create an empty ADS library after validating its name.
- Parameters:
- Returns:
Metadata returned by ADS for the newly created library.
- Return type:
- Raises:
ValueError – If name is empty after trimming.
- export_library(library_id, format='bibtex', *, cancelled=None)[source]
Read the complete remote library and export its bibliography.
- Parameters:
- Returns:
Full bibliography and sorted Bibcodes, an empty result for an empty library, or a cancelled result without partial bibliography text.
- Return type:
- Raises:
ADSError – If library pagination is incomplete or export records are missing.
ValueError – If the library identifier or format is invalid.
- preflight(library_id, bibcodes)[source]
Classify requested Bibcodes against the current remote library.
Missing Bibcodes are returned in AddDocumentsResult.unattempted because no add request has been made.
- Parameters:
library_id (str)
bibcodes (collections.abc.Sequence[str])
- Return type:
- reconcile_and_retry(library_id, bibcodes, *, cancelled=<function AdsLibraryService.<lambda>>)[source]
Reload remote state and retry only Bibcodes still absent.
- Parameters:
library_id (str)
bibcodes (collections.abc.Sequence[str])
cancelled (collections.abc.Callable[[], bool])
- Return type:
- class adsfolio.library_sync.BibcodeSelection(bibcodes, source_files, ineligible_files, local_duplicate_files)[source]
Bases:
objectStable local Bibcode selection and exclusion counts.
- Parameters:
- class adsfolio.library_sync.LibraryDestination(id, name, permission, public, num_documents)[source]
Bases:
objectImmutable ADS library metadata used by callers and UI code.
- class adsfolio.library_sync.LibraryExportResult(text, bibcodes, cancelled=False)[source]
Bases:
objectComplete remote bibliography, or an explicitly cancelled operation.
- adsfolio.library_sync.collect_identified_bibcodes(records)[source]
Collect eligible Bibcodes from local identification records.
- Parameters:
records (iterable of mapping) – Local records containing status, document identity, and Bibcode data.
- Returns:
First-seen unique Bibcodes and counts for all excluded or duplicate source records.
- Return type: