backend.crossref module

class backend.crossref.CrossRefAPI[source]

Bases: object

Fetches papers from CrossRef

create_paper_by_doi(doi)[source]

Fetches the metadata with content-negotiation to create the paper.

Returns:a Paper object or None if there was an error
save_doi_metadata(metadata, extra_orcids=None)[source]

Given the metadata as Citeproc+JSON or from CrossRef, create the associated paper and publication

Parameters:extra_orcids – an optional orcids list, which will be unified with the orcids extracted from the metadata. This is useful for the ORCID interface.
Returns:the paper, created if needed
search_for_dois_incrementally(query, filters={}, max_batches=10)[source]

Searches for DOIs for the given query and yields their metadata as it finds them.

Parameters:
  • query – the search query to pass to CrossRef
  • filters – filters as specified by the REST API
  • max_batches – maximum number of queries to send to CrossRef
backend.crossref.consolidate_publication(publi)[source]

Fetches the abstract from Zotero and adds it to the publication if it succeeds.

backend.crossref.convert_to_name_pair(dct)[source]

Converts a dictionary {‘family’:’Last’,’given’:’First’} to (‘First’,’Last’)

backend.crossref.create_publication(paper, metadata)[source]

Creates a BareOaiRecord entry based on the DOI metadata (as returned by the JSON format from CrossRef).

Parameters:
  • paper – the paper the publication object refers to
  • metadata – the CrossRef metadata (parsed from JSON)
Returns:

None if the metadata is invalid or the data does not fit in the database schema, otherwise the pair of the paper and the publication.

backend.crossref.fetch_dois(doi_list)[source]

Fetch the metadata of a list of DOIs from CrossRef, by batch if the server supports it, otherwise incrementally.

backend.crossref.fetch_dois_by_batch(doi_list)[source]

Fetch a list of DOIs by batch (useful when refreshing the list of publications of a given researcher, as the records have most likely been already cached before by the proxy)

backend.crossref.fetch_dois_incrementally(doi_list)[source]

Fetch a list of DOIs incrementally (useful when the proxy only supports this method or when we want to return the first metadata as soon as possible)

backend.crossref.fetch_metadata_by_DOI(doi)[source]

Fetch the metadata for a single DOI. This is supported by the standard proxy, dx.doi.org, as well as more advanced proxies such as doi_cache

backend.crossref.fetch_zotero_by_DOI(doi)[source]

Fetch Zotero metadata for a given DOI. Works only with the doi_cache proxy.

backend.crossref.get_publication_date(metadata)[source]

Get the publication date out of a record. If ‘issued’ is not present we default to ‘deposited’ although this might be quite inaccurate. But this case is rare anyway.

backend.crossref.is_oa_license(license_url)[source]

This function returns whether we expect a publication under a given license to be freely available from the publisher.

Licenses are as expressed in CrossRef: see http://api.crossref.org/licenses

backend.crossref.parse_crossref_date(date)[source]

Parse the date representation from CrossRef to a python object