本文整理汇总了Python中pymarc.record.Record.get_fields方法的典型用法代码示例。如果您正苦于以下问题:Python Record.get_fields方法的具体用法?Python Record.get_fields怎么用?Python Record.get_fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymarc.record.Record
的用法示例。
在下文中一共展示了Record.get_fields方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_remove_fields
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import get_fields [as 别名]
def test_remove_fields(self):
with open("test/testunimarc.dat", "rb") as fh:
record = Record(fh.read(), force_utf8=True)
self.assertTrue(len(record.get_fields("899")) != 0)
self.assertTrue(len(record.get_fields("702")) != 0)
record.remove_fields("899", "702")
self.assertTrue(len(record.get_fields("899")) == 0)
self.assertTrue(len(record.get_fields("702")) == 0)
示例2: test_remove_fields
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import get_fields [as 别名]
def test_remove_fields(self):
with open('test/testunimarc.dat', 'rb') as fh:
record = Record(fh.read(), force_utf8=True)
self.assertTrue(len(record.get_fields('899'))!=0)
self.assertTrue(len(record.get_fields('702'))!=0)
record.remove_fields('899', '702')
self.assertTrue(len(record.get_fields('899'))==0)
self.assertTrue(len(record.get_fields('702'))==0)
示例3: test_find
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import get_fields [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")
示例4: test_multi_find
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import get_fields [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_find
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import get_fields [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')
示例6: test_alphatag
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import get_fields [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")
示例7: test_multi_find
# 需要导入模块: from pymarc.record import Record [as 别名]
# 或者: from pymarc.record.Record import get_fields [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.assertEqual(len(found), 2)