"""a collection of tool to interrogate invenio store. Note: details on the invenio API at http://invenio-software.org/ """ 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) from .exception import (CdsException, Marc12Exception, RecordException, XmlException) 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 def load_record(host, record_id): """Helper function to load a single record from an invenio store. Args: host (str): host of the store. Possible values are ``cds.cern.ch`` or ``inspirehep.net``. record_id (int): the record identifier in the store Returns: Record or None: the decoded record when it exist, ``None`` otherwise. Raises: CdsException: when the server return an HTTP error. Marc12Exception: when a record is not well formed XML. """ store = InvenioStore(host) xml = store.get_record(record_id) svc = Marc12() records = svc(xml) if len(records) > 0: return records[0] return None