本文整理汇总了Python中pymarc.record.Record.add_field方法的典型用法代码示例。如果您正苦于以下问题:Python Record.add_field方法的具体用法?Python Record.add_field怎么用?Python Record.add_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymarc.record.Record
的用法示例。
在下文中一共展示了Record.add_field方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_notes
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import add_field [as 别名]
def test_notes(self):
record = Record()
self.assertEquals(record.notes(), [])
record.add_field(
Field("500", [" ", " "], subfields=["a", "Recast in bronze from artist's plaster original of 1903."])
)
self.assertEquals(record.notes()[0].format_field(), "Recast in bronze from artist's plaster original of 1903.")
示例2: test_pubyear
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import add_field [as 别名]
def test_pubyear(self):
record = Record()
self.assertEqual(record.pubyear(), None)
record.add_field(
Field(
"260",
[" ", " "],
subfields=[
"a",
"Paris :",
"b",
"Gauthier-Villars ;",
"a",
"Chicago :",
"b",
"University of Chicago Press,",
"c",
"1955.",
],
)
)
self.assertEqual(record.pubyear(), "1955.")
record = Record()
self.assertEqual(record.pubyear(), None)
record.add_field(Field("264", [" ", "1"], subfields=["a", "London :", "b", "Penguin,", "c", "1961."]))
self.assertEqual(record.pubyear(), "1961.")
示例3: test_add_field
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import add_field [as 别名]
def test_add_field(self):
record = Record()
field = Field(
tag = '245',
indicators = ['1', '0'],
subfields = ['a', 'Python', 'c', 'Guido'])
record.add_field(field)
self.assertTrue(field in record.fields, msg='found field')
示例4: test_multi_find
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import add_field [as 别名]
def test_multi_find(self):
record = Record()
subject1 = Field(tag="650", indicators=["", "0"], subfields=["a", "Programming Language"])
record.add_field(subject1)
subject2 = Field(tag="651", indicators=["", "0"], subfields=["a", "Object Oriented"])
record.add_field(subject2)
found = record.get_fields("650", "651")
self.assertEquals(len(found), 2)
示例5: test_title
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import add_field [as 别名]
def test_title(self):
record = Record()
self.assertEquals(record.title(), None)
record.add_field(Field("245", [0, 1], subfields=["a", "Foo :", "b", "bar"]))
self.assertEquals(record.title(), "Foo :bar")
record = Record()
record.add_field(Field("245", [0, 1], subfields=["a", "Farghin"]))
self.assertEquals(record.title(), "Farghin")
示例6: test_init_with_leader
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import add_field [as 别名]
def test_init_with_leader(self):
"""
Test creating a Record with a leader argument.
"""
record = Record(leader="abcdefghijklmnopqrstuvwx")
record.add_field(Field(tag="245", indicators=["0", "1"], subfields=["a", "The pragmatic programmer"]))
transmission_format = record.as_marc()
transmission_format_leader = transmission_format[0:24]
self.assertEqual(transmission_format_leader, b"00067fghij2200037rst4500")
示例7: test_uniformtitle
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import add_field [as 别名]
def test_uniformtitle(self):
record = Record()
self.assertEquals(record.uniformtitle(), None)
record.add_field(Field("130", [0, " "], subfields=["a", "Tosefta.", "l", "English.", "f", "1977."]))
self.assertEquals(record.uniformtitle(), "Tosefta. English. 1977.")
record = Record()
record.add_field(Field("240", [1, 4], subfields=["a", "The Pickwick papers.", "l", "French."]))
self.assertEquals(record.uniformtitle(), "The Pickwick papers. French.")
示例8: test_membership
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import add_field [as 别名]
def test_membership(self):
record = Record()
title = Field(
tag = '245',
indicators = ['1', '0'],
subfields = ['a', 'Python', 'c', 'Guido'])
record.add_field(title)
self.assertTrue('245' in record)
self.assertFalse('999' in record)
示例9: test_alphatag
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import add_field [as 别名]
def test_alphatag(self):
record = Record()
record.add_field(Field('CAT', [' ', ' '], subfields=['a', 'foo']))
record.add_field(Field('CAT', [' ', ' '], subfields=['b', 'bar']))
fields = record.get_fields('CAT')
self.assertEqual(len(fields), 2)
self.assertEqual(fields[0]['a'], 'foo')
self.assertEqual(fields[1]['b'], 'bar')
self.assertEqual(record['CAT']['a'], 'foo')
示例10: test_quick_access
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import add_field [as 别名]
def test_quick_access(self):
record = Record()
title = Field(
tag = '245',
indicators = ['1', '0'],
subfields = ['a', 'Python', 'c', 'Guido'])
record.add_field(title)
self.assertEqual(record['245'], title, 'short access')
self.assertEqual(record['999'], None, 'short access with no field')
示例11: test_author
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import add_field [as 别名]
def test_author(self):
record = Record()
self.assertEquals(record.author(), None)
record.add_field(Field("100", [1, 0], subfields=["a", "Bletch, Foobie,", "d", "1979-1981."]))
self.assertEquals(record.author(), "Bletch, Foobie, 1979-1981.")
record = Record()
record.add_field(Field("130", [0, " "], subfields=["a", "Bible.", "l", "Python."]))
self.assertEquals(record.author(), None)
示例12: test_init_with_no_leader
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import add_field [as 别名]
def test_init_with_no_leader(self):
"""
Test creating a Record object with no leader argument.
"""
record = Record()
record.add_field(Field(tag="245", indicators=["0", "1"], subfields=["a", "The pragmatic programmer"]))
transmission_format = record.as_marc()
transmission_format_leader = transmission_format[0:24]
self.assertEqual(transmission_format_leader, b"00067 2200037 4500")
示例13: test_author
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import add_field [as 别名]
def test_author(self):
record = Record()
self.assertEqual(record.author(), None)
record.add_field(Field('100', [1, 0],
subfields=['a', 'Bletch, Foobie,', 'd', '1979-1981.']))
self.assertEqual(record.author(), 'Bletch, Foobie, 1979-1981.')
record = Record()
record.add_field(Field('130', [0, ' '],
subfields=['a', 'Bible.', 'l', 'Python.']))
self.assertEqual(record.author(), None)
示例14: test_title
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import add_field [as 别名]
def test_title(self):
record = Record()
self.assertEqual(record.title(), None)
record.add_field(Field('245', [0, 1],
subfields=['a', 'Foo :', 'b', 'bar']))
self.assertEqual(record.title(), 'Foo :bar')
record = Record()
record.add_field(Field('245', [0, 1],
subfields=['a', "Farghin"]))
self.assertEqual(record.title(), "Farghin")
示例15: test_find
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import add_field [as 别名]
def test_find(self):
record = Record()
subject1 = Field(tag="650", indicators=["", "0"], subfields=["a", "Programming Language"])
record.add_field(subject1)
subject2 = Field(tag="650", indicators=["", "0"], subfields=["a", "Object Oriented"])
record.add_field(subject2)
found = record.get_fields("650")
self.assertEqual(found[0], subject1, "get_fields() item 1")
self.assertEqual(found[0], subject1, "get_fields() item 2")
found = record.get_fields()
self.assertEqual(len(found), 2, "get_fields() with no tag")