__init__.py 3.3 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
from .authorsmixin import AuthorsMixin, to_initial
8 9 10 11 12 13 14
from .base import (ARXIV,
                   ARXIV_PDF,
                   is_conference,
                   is_institute,
                   is_thesis,
                   MSG_NO_CONF,
                   MSG_NO_COUNTRY,
15
                   MSG_NO_ENTRY,
16 17
                   MSG_NO_PUBLISHER,
                   MSG_NO_THESIS,
18 19
                   MSG_TOOMANY_SYNONYM,
                   MSG_UNKNOWN_COLLABORATION,
20
                   MSG_WELL_FORMED_COLLABORATION,
21
                   OAI,
22 23 24
                   OAI_URL,
                   REG_ARXIV_NUMBER,
                   REG_AUTHOR,
25 26
                   REG_DATE,
                   REG_DATE_YYYYMM,
27 28
                   REG_OAI,
                   REG_YEAR,
29
                   search_synonym,
30
                   THESIS_DIR)
31

32 33 34 35
from .exception import (CheckException,
                        RecordException,
                        StoreException,
                        ToolException)
36

37
from .factory import build_record, build_store
38
from .inspirehepstore import InspirehepStore
39
from .publicationinfomixin import PublicationInfoMixin
40
from .cdsstore import CdsStore
41
from .recordcdsconfpaper import RecordCdsConfPaper
42 43
from .recordcdspubli import RecordCdsPubli
from .recordcdsthesis import RecordCdsThesis
44
from .recordhepconfpaper import RecordHepConfPaper
45 46
from .recordhepinst import RecordHepInst
from .recordheppubli import RecordHepPubli
47
from .recordhepthesis import RecordHepThesis
48 49


50
def load_record(host, record_id, shelf=None):
51 52 53
    """Helper function to load a single record from an invenio store.

    Args:
54 55 56 57 58 59
        host (str):
            host of the store. Possible values are ``cds.cern.ch``
            or ``inspirehep.net``.

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

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
        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/ |
             +----------------+--------------+-----------------------------+


78
    Returns:
79
        RecordCds:
80
            either RecordCdsConfPaper, RecordHepConfPaper, RecodHepPubli, RecordHepInst,
81
            RecordHepThesis, RecordHepInst, RecordCdsPubli or RecordCdsThesis
82

83
    Raises:
84
        StoreException::
LE GAC Renaud's avatar
LE GAC Renaud committed
85

86 87
            * the server return an HTTP error.
            * no JSON object could be decoded.
88

89
    """
90
    store = build_store(host, shelf=shelf)
91
    recjson = store.get_record(record_id)
92
    return build_record(recjson, shelf=shelf)