API reference
Generated from the source with mkdocstrings. Everything below imports from
bibliofabric.signposting.
Client
bibliofabric.signposting.SignpostingClient
Client that reads the signposting of a landing page or DOI.
The resolver has no base URL of its own: :meth:resolve sends the
caller's landing page URL as given, and :meth:resolve_doi resolves a
DOI through the DOI System proxy at https://doi.org first. Both
methods send HEAD and follow redirect hops themselves, so the
Link header of the answer that ends the chase is parsed with
:func:bibliofabric.paging.parse_link_header and an attribute-aware
reader; a server that answers HTTP 405 to HEAD is retried with
GET, of which only the headers are read. A linkset link is
followed when the landing page advertises one, and the link set
document (JSON or application/linkset) is parsed into a typed
:class:~bibliofabric.signposting.models.SignpostingLinkset.
resolve(url: str) -> SignpostingResult
async
Return the signposting of the landing page at url.
Sends HEAD to url (an absolute http or https URL;
anything else raises
:class:bibliofabric.exceptions.ConfigurationError), follows
redirects hop by hop, and parses the Link header of the answer
that ends the chase. A hop that answers HTTP 405 to HEAD is
retried with GET. A linkset link in the header is followed
and its document parsed; a link set that cannot be fetched raises
the fetch error.
resolve_doi(doi: str) -> SignpostingResult
async
Return the signposting of the landing page a DOI resolves to.
Sends HEAD https://doi.org/{doi} and follows the resolver's
redirects to the landing page; the rest behaves like
:meth:resolve. An unknown DOI answers HTTP 404, which raises
:class:bibliofabric.exceptions.NotFoundError; a string that is
not a DOI name raises
:class:bibliofabric.exceptions.ConfigurationError.
Every member above also exists on SignpostingSyncClient, the synchronous
twin; see Async and sync clients.
Settings
bibliofabric.signposting.SignpostingSettings
Signposting resolver client settings.
Inherits timeout, max_retries, max_retry_wait,
max_requests_per_second, max_concurrency, user_agent,
mailto and follow_redirects from
:class:bibliofabric.config.BaseApiSettings and sets resolver defaults
(2 req/s, concurrency 2, timeout 60 s). No credentials exist; the
resolver talks to public landing pages only.
The client has no base URL of its own: every landing page URL arrives
with the call, and follow_redirects stays False because the
client follows redirect hops itself to read each hop's Link header.
Models
bibliofabric.signposting.SignpostingResult
The signposting of one landing page.
url is the landing page: the URL of the response whose Link
header was parsed, after following redirects. status is that
response's HTTP status code. links lists every parsed link in order.
link_urls maps each relation type to the URL of its first link, the
plain bibliofabric.paging.parse_link_header mapping. linkset is
set when the client followed the landing page's linkset link.
bibliofabric.signposting.SignpostingLink
One typed link with its RFC 8288 target attributes.
media_type carries the wire type attribute, the MIME type of the
target resource. profile carries the profile attribute, a URI
that narrows the format beyond the MIME type. anchor carries the
explicit link context when the link declares one; links without it are
anchored at the resource that emitted them. Unknown attributes (for
example title or datetime) are absorbed through extra="allow".
bibliofabric.signposting.SignpostingLinkset
A link set document (RFC 9264) with one group per anchor.
extra="allow" keeps members an RFC 9264 extension profile adds.
bibliofabric.signposting.SignpostingLinksetGroup
Every link of a link set that shares one anchor (link context).
Parsed from one link context object of an application/linkset+json
document or from the links that share an anchor in an
application/linkset document. anchor is None for a group
whose context defaults to the URI of the link set document itself.
Helpers
bibliofabric.signposting.parse_links(value: str | None, base_url: str) -> list[SignpostingLink]
Parse every link of an RFC 8288 header value, resolved against base_url.
One entry with several space-separated rel tokens produces one link
per token. Relative href and anchor values resolve against
base_url. Attribute names are case-insensitive; entries without a
URL or a rel parameter contribute nothing, and a None or empty
value parses to an empty list.
bibliofabric.signposting.link_urls(value: str | None) -> dict[str, str]
Return the plain rel-to-URL map of a Link header value.
The first entry of each relation token wins, the
:func:bibliofabric.paging.parse_link_header contract.
bibliofabric.signposting.linkset_from_links(links: list[SignpostingLink], document_url: str) -> SignpostingLinkset
Group parsed links of an application/linkset body by their anchor.
Links without an anchor attribute belong to the context of the link
set document itself (RFC 9264, Section 4), so their group anchor is
document_url.
bibliofabric.signposting.normalize_doi(value: str) -> str
Return the bare DOI for a DOI, DOI URL, or doi: string.
Accepts 10.1038/nature12373, https://doi.org/10.1038/nature12373,
and doi:10.1038/nature12373. Anything else raises
:class:bibliofabric.exceptions.ConfigurationError. The rule mirrors
:func:bibliofabric.doi.dialect.normalize_doi.