示例#1
0
def test_output_type_from_dumps_etree():
    """Test output type from dumps_etree."""
    path = os.path.dirname(__file__)
    data = list(load("{0}/demo_marc21_to_dc.xml".format(path)))
    # test without arguments
    output1 = dumps_etree(data)
    # test with xslt_filename argument
    output2 = dumps_etree(data, xslt_filename="{0}/demo_marc21_to_dc.xslt".format(path))
    # it should not generate a TypeError exception
    assert isinstance(output1, _Element)
    assert isinstance(output2, _Element)
def test_output_type_from_dumps_etree():
    """Test output type from dumps_etree."""
    path = os.path.dirname(__file__)
    data = list(load('{0}/demo_marc21_to_dc.xml'.format(path)))
    # test without arguments
    output1 = dumps_etree(data)
    # test with xslt_filename argument
    output2 = dumps_etree(
        data,
        xslt_filename='{0}/demo_marc21_to_dc.xslt'.format(path)
    )
    # it should not generate a TypeError exception
    assert isinstance(output1, _Element)
    assert isinstance(output2, _Element)
示例#3
0
    def serialize_oaipmh(self, pid, record):
        """Serialize a single record for OAI-PMH."""
        obj = self.transform_record(pid, record['_source']) \
            if isinstance(record['_source'], Record) \
            else self.transform_search_hit(pid, record)

        return dumps_etree(obj, **self.dumps_kwargs)
示例#4
0
    def serialize_oaipmh(self, pid, record):
        """Serialize a single record for OAI-PMH."""
        obj = self.transform_record(pid, record['_source']) \
            if isinstance(record['_source'], Record) \
            else self.transform_search_hit(pid, record)

        return dumps_etree(obj, **self.dumps_kwargs)
def dumps_etree(pid, record, **kwargs):
    """Dump MARC21 compatible record.

    :param pid: The :class:`invenio_pidstore.models.PersistentIdentifier`
        instance.
    :param record: The :class:`invenio_records.api.Record` instance.
    :returns: A LXML Element instance.
    """
    from dojson.contrib.to_marc21 import to_marc21
    from dojson.contrib.to_marc21.utils import dumps_etree

    return dumps_etree(to_marc21.do(record["_source"]), **kwargs)
示例#6
0
def dumps_etree(pid, record, **kwargs):
    """Dump MARC21 compatible record.

    :param pid: The :class:`invenio_pidstore.models.PersistentIdentifier`
        instance.
    :param record: The :class:`invenio_records.api.Record` instance.
    :returns: A LXML Element instance.
    """
    from dojson.contrib.to_marc21 import to_marc21
    from dojson.contrib.to_marc21.utils import dumps_etree

    return dumps_etree(to_marc21.do(record['_source']), **kwargs)
示例#7
0
文件: marcxml.py 项目: N03/invenio
    def serialize_oaipmh(self, pid, record):
        """Serialize a single record for OAI-PMH.

        :param pid: The :class:`invenio_pidstore.models.PersistentIdentifier`
            instance.
        :param record: The :class:`invenio_records.api.Record` instance.
        :returns: The object serialized.
        """
        obj = self.transform_record(pid, record['_source']) \
            if isinstance(record['_source'], Record) \
            else self.transform_search_hit(pid, record)

        return dumps_etree(obj, **self.dumps_kwargs)
示例#8
0
    def serialize_oaipmh(self, pid, record):
        """Serialize a single record for OAI-PMH.

        :param pid: The :class:`invenio_pidstore.models.PersistentIdentifier`
            instance.
        :param record: The :class:`invenio_records.api.Record` instance.
        :returns: The object serialized.
        """
        obj = self.transform_record(pid, record['_source']) \
            if isinstance(record['_source'], Record) \
            else self.transform_search_hit(pid, record)

        return dumps_etree(obj, **self.dumps_kwargs)
示例#9
0
def dump_etree(record, **kwargs):
    """Test dumper."""
    from dojson.contrib.to_marc21.utils import dumps_etree
    return dumps_etree({'245__': {'a': record['title']}}, **kwargs)
示例#10
0
def dumps_etree(pid, record, **kwargs):
    """Dump MARC21 compatible record."""
    from dojson.contrib.to_marc21 import to_marc21
    from dojson.contrib.to_marc21.utils import dumps_etree

    return dumps_etree(to_marc21.do(record['_source']), **kwargs)
示例#11
0
def dump_etree(record, **kwargs):
    """Test dumper."""
    from dojson.contrib.to_marc21.utils import dumps_etree
    return dumps_etree({'245__': {'a': record['title']}}, **kwargs)