Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

__init__.py 1.77 KB
Newer Older
1
"""a collection of tool to interrogate invenio store.
2

3 4
Note:
    details on the invenio  API at http://invenio-software.org/
5 6

"""
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
from .base import (ARXIV,
                   ARXIV_PDF,
                   is_conference,
                   is_institute,
                   is_thesis,
                   MSG_NO_CONF,
                   MSG_NO_COUNTRY,
                   MSG_NO_PUBLISHER,
                   MSG_NO_THESIS,
                   MSG_WELL_FORMED_COLLABORATION,
                   OAI_URL,
                   REG_ARXIV_NUMBER,
                   REG_AUTHOR,
                   REG_OAI,
                   REG_YEAR,
                   THESIS_DIR)
23

24 25 26 27
from .exception import (CdsException,
                        Marc12Exception,
                        RecordException,
                        XmlException)
28

29 30 31 32 33 34 35 36
from .inveniostore import InvenioStore
from .iterrecord import IterRecord, REG_INT
from .marc12 import Marc12
from .record import Record
from .recordconf import RecordConf
from .recordinst import RecordInst
from .recordpubli import DECODE_REF, RecordPubli
from .recordthesis import RecordThesis
37 38 39 40 41 42


def load_record(host, record_id):
    """Helper function to load a single record from an invenio store.

    Args:
43
        host (str): host of the store.
44
            Possible values are ``cds.cern.ch`` or ``inspirehep.net``.
LE GAC Renaud's avatar
LE GAC Renaud committed
45
        record_id (int): the record identifier in the store
46 47

    Returns:
48
        Record or None: the decoded record when it exist, ``None`` otherwise.
49

50 51 52 53
    Raises:
        CdsException: when the server return an HTTP error.
        Marc12Exception: when a record is not well formed XML.

54 55 56 57 58
    """
    store = InvenioStore(host)
    xml = store.get_record(record_id)

    svc = Marc12()
59 60 61 62 63
    records = svc(xml)
    if len(records) > 0:
        return records[0]

    return None