• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python record.Record类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pymarc.record.Record的典型用法代码示例。如果您正苦于以下问题:Python Record类的具体用法?Python Record怎么用?Python Record使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Record类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_pubyear

    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.")
开发者ID:cshintov,项目名称:pymarc,代码行数:27,代码来源:record.py


示例2: test_notes

 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.")
开发者ID:gsf,项目名称:pymarc,代码行数:7,代码来源:record.py


示例3: test_remove_fields

 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)
开发者ID:cshintov,项目名称:pymarc,代码行数:8,代码来源:record.py


示例4: test_add_field

 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')
开发者ID:acdha,项目名称:pymarc,代码行数:8,代码来源:record.py


示例5: test_remove_fields

 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)
开发者ID:stancikcom,项目名称:pymarc,代码行数:8,代码来源:record.py


示例6: test_membership

 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)
开发者ID:acdha,项目名称:pymarc,代码行数:9,代码来源:record.py


示例7: test_quick_access

 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')
开发者ID:acdha,项目名称:pymarc,代码行数:9,代码来源:record.py


示例8: test_alphatag

 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')
开发者ID:acdha,项目名称:pymarc,代码行数:9,代码来源:record.py


示例9: test_init_with_no_leader

 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")
开发者ID:cshintov,项目名称:pymarc,代码行数:9,代码来源:record.py


示例10: test_init_with_leader

 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")
开发者ID:cshintov,项目名称:pymarc,代码行数:9,代码来源:record.py


示例11: test_pubyear

    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.')
开发者ID:Gluejar,项目名称:pymarc,代码行数:12,代码来源:record.py


示例12: test_as_marc_with_explicit_leader

 def test_as_marc_with_explicit_leader(self):
     """
     Test setting an explicit leader.
     as_marc() should use the whole leader as set.
     """
     record = Record()
     record.add_field(Field(tag="245", indicators=["0", "1"], subfields=["a", "The pragmatic programmer"]))
     record.leader = "00067     2200037   4500"
     leader_not_touched = record.leader
     transmission_format = record.as_marc()
     leader_touched = record.leader
     self.assertTrue(leader_not_touched == leader_touched)
开发者ID:cshintov,项目名称:pymarc,代码行数:12,代码来源:record.py


示例13: standardize_maemarc

def standardize_maemarc(fid, mae_marc, fname_suffix):
	marc_file = MARC_FILE % fname_suffix

	mae_marc = mae_marc.replace("\r", "")
	mae_marc = mae_marc.strip()
	mae_marc = mae_marc.rstrip("&")
	mae_marc = mae_marc.rstrip("%")
	
	parts = mae_marc.split('\n')

	header = parts[:2]
	tags_values =  parts[2:]
	ret = []

	writer = MARCWriter(file(marc_file, 'a+'))
	record = Record()
	control = parts[1:2][0][:-1]
	field = Field(tag = '001', data = fid)
	record.add_field(field)
	#field = Field(tag = '008', data = control) 
	#record.add_field(field)

	for dat in tags_values:
		dat = dat.strip('\n')
		tag = dat[0:3]
		values = []
		subfields = []
		for v in dat[6:-1].split('$'):
			subfield = v[:1]
			value = v[1:]
			if (tag == '260') and (subfield == 'c'):
				value = value.lstrip('c')
				value = value.rstrip(".")
				
			subfields.append(subfield)
			subfields.append(value)
			
		if tag == '245':
			indicator = ['1', '0']
		elif tag == '041':
			indicator = ['1', '0']
		else:
			indicator = ['', '']
		field = Field(tag, indicator, subfields)
		record.add_field(field)

		if tag:
			ret.append({tag:subfields})

	print "final output:"
	print record
	writer.write(record)
	writer.close()
开发者ID:lonbriones,项目名称:estella,代码行数:53,代码来源:getmarc.py


示例14: test_as_marc_leader

 def test_as_marc_leader(self):
     record = Record()
     record.add_field(
         Field(
             tag = '245', 
             indicators = ['0','1'],
             subfields = ['a', 'The pragmatic programmer']))
     record.leader = '00067     2200037   4500'
     leader_not_touched = record.leader
     transmission_format = record.as_marc()
     leader_touched = record.leader
     self.assertTrue(leader_not_touched==leader_touched)
开发者ID:stancikcom,项目名称:pymarc,代码行数:12,代码来源:record.py


示例15: test_title

    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")
开发者ID:gsf,项目名称:pymarc,代码行数:9,代码来源:record.py


示例16: test_uniformtitle

    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.")
开发者ID:gsf,项目名称:pymarc,代码行数:9,代码来源:record.py


示例17: test_author

    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)
开发者ID:gsf,项目名称:pymarc,代码行数:9,代码来源:record.py


示例18: test_remove_field

    def test_remove_field(self):
        record = Record()
        field = Field(tag="245", indicators=["1", "0"], subfields=["a", "Python", "c", "Guido"])
        record.add_field(field)
        self.assertEqual(record["245"]["a"], "Python")

        # try removing a field that exists
        record.remove_field(field)
        self.assertEqual(record["245"], None)

        # try removing a field that doesn't exist
        field = Field("001", data="abcd1234")
        self.assertRaises(FieldNotFound, record.remove_field, field)
开发者ID:gsf,项目名称:pymarc,代码行数:13,代码来源:record.py


示例19: test_title

    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")
开发者ID:acdha,项目名称:pymarc,代码行数:11,代码来源:record.py


示例20: test_author

 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)
开发者ID:acdha,项目名称:pymarc,代码行数:11,代码来源:record.py



注:本文中的pymarc.record.Record类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pymarkovchain.MarkovChain类代码示例发布时间:2022-05-25
下一篇:
Python pymarc.Record类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap