__init__.py 2.81 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, build_store
28 29 30
from .inveniostore import InvenioStore
from .record import Record
from .recordconf import RecordConf
31 32 33
from .recordhepconf import RecordHepConf
from .recordhepinst import RecordHepInst
from .recordheppubli import RecordHepPubli
34
from .recordhepthesis import RecordHepThesis
LE GAC Renaud's avatar
LE GAC Renaud committed
35
from .recordpubli import RecordPubli
36
from .recordthesis import RecordThesis
37 38


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

    Args:
43 44 45 46 47 48
        host (str):
            host of the store. Possible values are ``cds.cern.ch``
            or ``inspirehep.net``.

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

50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
        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/ |
             +----------------+--------------+-----------------------------+


67
    Returns:
68
        Record:
69 70
            either RecordConf, RecordHepConf, RecodHepPubli, RecordHepInst,
            RecordHepThesis, RecordHepInst, RecordPubli or RecordThesis
71

72
    Raises:
LE GAC Renaud's avatar
LE GAC Renaud committed
73 74
        CdsException::

75 76
            * the server return an HTTP error.
            * no JSON object could be decoded.
77

78
    """
79
    store = build_store(host, shelf=shelf)
80
    recjson = store.get_record(record_id)
81
    return build_record(recjson, shelf=shelf)