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

3
Note:
4
    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
from .exception import (CdsException,
25
                        RecordException)
26

27
from .factory import build_record
28 29 30 31
from .inveniostore import InvenioStore
from .record import Record
from .recordconf import RecordConf
from .recordinst import RecordInst
LE GAC Renaud's avatar
LE GAC Renaud committed
32
from .recordpubli import RecordPubli
33
from .recordthesis import RecordThesis
34 35


36
def load_record(host, record_id, shelf=None):
37 38 39
    """Helper function to load a single record from an invenio store.

    Args:
40 41 42 43 44 45
        host (str):
            host of the store. Possible values are ``cds.cern.ch``
            or ``inspirehep.net``.

        record_id (int):
            the record identifier in the store
46

47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
        shelf (str):
            section of the store containing records. It depends on the host.
            Possible values are ``None``, ``literature``, ``conferences``
            and ``institutions``

             +----------------+--------------+-----------------------------+
             | host           | shelf        | base API                    |
             +----------------+--------------+-----------------------------+
             | cds.cern.ch    | None         | https://cds.cern.ch/        |
             +----------------+--------------+-----------------------------+
             | inspirehep.net | None         | https://old.inspirehep.net/ |
             | inspirehep.net | literature   | https://old.inspirehep.net/ |
             | inspirehep.net | conferences  | https://inspirehep.net/     |
             | inspirehep.net | institutions | https://old.inspirehep.net/ |
             +----------------+--------------+-----------------------------+


64
    Returns:
65 66
        Record:
            either RecordPubli, RecordInst, RecordConf of RecordThesis.
67

68
    Raises:
LE GAC Renaud's avatar
LE GAC Renaud committed
69 70
        CdsException::

71 72
            * the server return an HTTP error.
            * no JSON object could be decoded.
73

74
    """
75
    store = InvenioStore(host, shelf=shelf)
76 77
    recjson = store.get_record(record_id)
    return build_record(recjson)