inspirehep.modules.records.serializers package¶
Subpackages¶
- inspirehep.modules.records.serializers.fields package
- inspirehep.modules.records.serializers.schemas package
- Subpackages
- inspirehep.modules.records.serializers.schemas.json package
- Subpackages
- inspirehep.modules.records.serializers.schemas.json.authors package
- inspirehep.modules.records.serializers.schemas.json.literature package
- Subpackages
- inspirehep.modules.records.serializers.schemas.json.literature.common package
- Submodules
- inspirehep.modules.records.serializers.schemas.json.literature.common.accelerator_experiment module
- inspirehep.modules.records.serializers.schemas.json.literature.common.author module
- inspirehep.modules.records.serializers.schemas.json.literature.common.citation_item module
- inspirehep.modules.records.serializers.schemas.json.literature.common.collaboration module
- inspirehep.modules.records.serializers.schemas.json.literature.common.collaboration_with_suffix module
- inspirehep.modules.records.serializers.schemas.json.literature.common.conference_info_item module
- inspirehep.modules.records.serializers.schemas.json.literature.common.doi module
- inspirehep.modules.records.serializers.schemas.json.literature.common.external_system_identifier module
- inspirehep.modules.records.serializers.schemas.json.literature.common.isbn module
- inspirehep.modules.records.serializers.schemas.json.literature.common.publication_info_item module
- inspirehep.modules.records.serializers.schemas.json.literature.common.reference_item module
- inspirehep.modules.records.serializers.schemas.json.literature.common.supervisor module
- inspirehep.modules.records.serializers.schemas.json.literature.common.thesis_info module
- Module contents
- inspirehep.modules.records.serializers.schemas.json.literature.common package
- Module contents
- Subpackages
- Module contents
- Subpackages
- inspirehep.modules.records.serializers.schemas.latex package
- inspirehep.modules.records.serializers.schemas.json package
- Submodules
- inspirehep.modules.records.serializers.schemas.base module
- Module contents
- Subpackages
- inspirehep.modules.records.serializers.writers package
Submodules¶
inspirehep.modules.records.serializers.config module¶
-
inspirehep.modules.records.serializers.config.
COMMON_FIELDS_FOR_ENTRIES
= ['key', 'SLACcitation', 'archivePrefix', 'doi', 'eprint', 'month', 'note', 'primaryClass', 'title', 'url', 'year']¶ BibTeX fields shared among all bibtex entries.
-
inspirehep.modules.records.serializers.config.
FIELDS_FOR_ENTRY_TYPE
= {'inbook': ['chapter', 'publisher', 'author', 'series', 'number', 'volume', 'edition', 'editor', 'reportNumber', 'address', 'type', 'pages'], 'proceedings': ['publisher', 'series', 'number', 'volume', 'reportNumber', 'editor', 'address', 'organization', 'pages'], 'book': ['publisher', 'isbn', 'author', 'series', 'number', 'volume', 'edition', 'editor', 'reportNumber', 'address'], 'techreport': ['author', 'collaboration', 'number', 'address', 'type', 'institution'], 'phdthesis': ['reportNumber', 'school', 'address', 'type', 'author'], 'inproceedings': ['publisher', 'author', 'series', 'booktitle', 'number', 'volume', 'reportNumber', 'editor', 'address', 'organization', 'pages'], 'mastersthesis': ['reportNumber', 'school', 'address', 'type', 'author'], 'article': ['author', 'journal', 'collaboration', 'number', 'volume', 'reportNumber', 'pages'], 'misc': ['howpublished', 'reportNumber', 'author']}¶ Specific fields for a given bibtex entry.
Note
Since we’re trying to match as many as possible it doesn’t matter whether they’re mandatory or optional
-
inspirehep.modules.records.serializers.config.
MAX_AUTHORS_BEFORE_ET_AL
= 10¶ Maximum number of authors to be displayed without truncation.
Note
For more than
MAX_AUTHORS_BEFORE_ET_AL
only the first author should be displayed and a suitable truncation method is applied.
inspirehep.modules.records.serializers.fields_export module¶
-
inspirehep.modules.records.serializers.fields_export.
bibtex_document_type
(doc_type, obj)[source]¶ Return the BibTeX entry type.
Maps the INSPIRE
document_type
to a BibTeX entry type. Also checksthesis_info.degree_type
in case it’s a thesis, as it stores the information on which kind of thesis we’re dealing with.Parameters: - doc_type (text_type) – INSPIRE document type.
- obj (dict) – literature record.
Returns: bibtex document type for the given INSPIRE entry.
Return type: text_type
-
inspirehep.modules.records.serializers.fields_export.
bibtex_type_and_fields
(data)[source]¶ Return a BibTeX doc type and fields needed to be included in a BibTeX record.
Parameters: data (dict) – inspire record Returns: bibtex document type and fields Return type: tuple
-
inspirehep.modules.records.serializers.fields_export.
extractor
(field)¶
Get corporate author of a record.
Note
Only used to generate author field if corporate_author is the author.
Extract names of people from an authors field given their roles.
Parameters: - authors – authors field of the record.
- role – string specifying the role ‘author’, ‘editor’, etc.
Returns: of names of people
Return type: list of text_type
-
inspirehep.modules.records.serializers.fields_export.
get_best_publication_info
(data)[source]¶ Return the most comprehensive publication_info entry.
Parameters: data (dict) – inspire record Returns: a publication_info entry or default if not found any Return type: dict
-
inspirehep.modules.records.serializers.fields_export.
get_country_name_by_code
(code, default=None)[source]¶ Return a country name string from a country code.
Parameters: - code (str) – country code in INSPIRE 2 letter format based on ISO 3166-1 alpha-2
- default – value to be returned if no country of a given code exists
Returns: name of a country, or
default
if no such country.Return type: text_type
-
inspirehep.modules.records.serializers.fields_export.
get_date
(data, doc_type)[source]¶ Return a publication/thesis/imprint date.
Parameters: - data (dict) – INSPIRE literature record to be serialized
- doc_type (text_type) – BibTeX document type, as reported by bibtex_document_type
Returns: publication date for a record.
Return type: PartialDate
-
inspirehep.modules.records.serializers.fields_export.
get_note
(data, doc_type)[source]¶ Write and addendum/errata information to the BibTeX note field.
Traverse publication_info looking for erratum and addendum in publication_info.material field and build a string of references to those publication entries.
Returns: formatted list of the errata and addenda available for a given record Return type: string
-
inspirehep.modules.records.serializers.fields_export.
make_extractor
()[source]¶ Create a function store decorator.
Creates a decorator function that is used to collect extractor functions. They are put in a dictionary with the field they extract as keys. An extractor function is a function which returns a BibTeX field value given an inspire record and a document type.
Returns: a decorator with a store for pre-processing/extracting functions. Return type: function
inspirehep.modules.records.serializers.json_literature module¶
Marshmallow based JSON serializer for records.
-
class
inspirehep.modules.records.serializers.json_literature.
FacetsJSONUISerializer
(schema_class=<class 'invenio_records_rest.schemas.json.RecordSchemaJSONV1'>, **kwargs)[source]¶ Bases:
invenio_records_rest.serializers.json.JSONSerializer
JSON brief format serializer.
-
class
inspirehep.modules.records.serializers.json_literature.
LiteratureCitationsJSONSerializer
(schema_class=<class 'invenio_records_rest.schemas.json.RecordSchemaJSONV1'>, **kwargs)[source]¶ Bases:
invenio_records_rest.serializers.json.JSONSerializer
inspirehep.modules.records.serializers.latex module¶
Latex serializer for records.
-
class
inspirehep.modules.records.serializers.latex.
LatexSerializer
(format, **kwargs)[source]¶ Bases:
invenio_records_rest.serializers.marshmallow.MarshmallowMixin
,invenio_records_rest.serializers.base.PreprocessorMixin
Latex serializer for records.
-
preprocess_record
(pid, record, links_factory=None, **kwargs)[source]¶ Prepare a record and persistent identifier for serialization.
-
serialize
(pid, record, links_factory=None, **kwargs)[source]¶ Serialize a single record and persistent identifier.
Parameters: - pid – Persistent identifier instance.
- record – Record instance.
- links_factory – Factory function for record links.
-
serialize_search
(pid_fetcher, search_result, links=None, item_links_factory=None)[source]¶ Serialize search result(s).
Parameters: - pid_fetcher – Persistent identifier fetcher.
- search_result – Elasticsearch search result.
- links – Dictionary of links to add to response.
Returns: serialized search result(s)
Return type:
-
inspirehep.modules.records.serializers.marcxml module¶
MARCXML serializer.
inspirehep.modules.records.serializers.pybtex_serializer_base module¶
BibTex serializer for records.
-
class
inspirehep.modules.records.serializers.pybtex_serializer_base.
PybtexSerializerBase
(schema, writer)[source]¶ Bases:
object
Pybtex serializer for records.
-
create_bibliography
(record_list)[source]¶ Create a pybtex bibliography from individual entries.
Parameters: record_list – A list of records of the bibliography. Returns: a serialized bibliography. Return type: str
-
create_bibliography_entry
(record)[source]¶ Get a texkey and bibliography entry for an inspire record.
Use the schema in
self.schema
to create a Pybtex bibliography entry and retrieve respective texkey from arecord
.Parameters: record – A literature record. Returns: bibliography entry as a (texkey, pybtex_entry) tuple. Return type: tuple
-
serialize
(pid, record, links_factory=None)[source]¶ Serialize a single Bibtex record.
Parameters: - pid – Persistent identifier instance.
- record – Record instance.
- links_factory – Factory function for the link generation, which are added to the response.
Returns: single serialized Bibtex record
Return type:
-
serialize_search
(pid_fetcher, search_result, links=None, item_links_factory=None)[source]¶ Serialize search result(s).
Parameters: - pid_fetcher – Persistent identifier fetcher.
- search_result – Elasticsearch search result.
- links – Dictionary of links to add to response.
Returns: serialized search result(s)
Return type:
-
inspirehep.modules.records.serializers.response module¶
Serialization response factories.
Responsible for creating a HTTP response given the output of a serializer.
-
inspirehep.modules.records.serializers.response.
facets_responsify
(serializer, mimetype)[source]¶ Create a Facets serializer
As aggregations were removed from search query, now second call to the server is required to acquire data for Facets
Parameters: - serializer – Serializer instance.
- mimetype – MIME type of response.
-
inspirehep.modules.records.serializers.response.
record_responsify_nocache
(serializer, mimetype)[source]¶ Create a Records-REST response serializer with no cache.
This is useful for formats such as bibtex where the code that generates the format might change so we don’t want to use caching
Parameters: - serializer – Serializer instance.
- mimetype – MIME type of response.
Module contents¶
Record serialization.