當前位置: 首頁>>代碼示例>>Python>>正文


Python Record.legacy_export_as_marc方法代碼示例

本文整理匯總了Python中invenio.modules.records.api.Record.legacy_export_as_marc方法的典型用法代碼示例。如果您正苦於以下問題:Python Record.legacy_export_as_marc方法的具體用法?Python Record.legacy_export_as_marc怎麽用?Python Record.legacy_export_as_marc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在invenio.modules.records.api.Record的用法示例。


在下文中一共展示了Record.legacy_export_as_marc方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_marc_export

# 需要導入模塊: from invenio.modules.records.api import Record [as 別名]
# 或者: from invenio.modules.records.api.Record import legacy_export_as_marc [as 別名]
    def test_marc_export(self):
        from invenio.modules.records.api import Record
        from invenio.legacy.bibrecord import create_record, record_xml_output

        rec = Record(json=test_record, master_format='marc')

        # Needed to properly set authors when generating MARC
        first = rec['authors'][0]
        additional = rec['authors'][1:]
        rec['_first_author'] = first
        rec['_additional_authors'] = additional

        output_marc = record_xml_output(
            create_record(rec.legacy_export_as_marc())[0]
        )
        try:
            self.assertEqual(test_marc, output_marc)
        except AssertionError:
            # Print diff in case of errors.
            import difflib
            diff = "".join(difflib.unified_diff(
                test_marc.splitlines(1),
                output_marc.splitlines(1)
            ))
            raise AssertionError(diff)

        form_json = rec.produce('json_for_form')
        for k, v in test_form_json.items():
            self.assertEqual(form_json[k], test_form_json[k])
開發者ID:SDSG-Invenio,項目名稱:zenodo,代碼行數:31,代碼來源:test_jsonext.py


注:本文中的invenio.modules.records.api.Record.legacy_export_as_marc方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。