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)
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)
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)
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)
def dump_etree(record, **kwargs): """Test dumper.""" from dojson.contrib.to_marc21.utils import dumps_etree return dumps_etree({'245__': {'a': record['title']}}, **kwargs)
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)