本文整理汇总了Python中iiif.info.IIIFInfo.read方法的典型用法代码示例。如果您正苦于以下问题:Python IIIFInfo.read方法的具体用法?Python IIIFInfo.read怎么用?Python IIIFInfo.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iiif.info.IIIFInfo
的用法示例。
在下文中一共展示了IIIFInfo.read方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test10_read_example_from_spec
# 需要导入模块: from iiif.info import IIIFInfo [as 别名]
# 或者: from iiif.info.IIIFInfo import read [as 别名]
def test10_read_example_from_spec(self):
"""Test reading of example from spec."""
i = IIIFInfo()
fh = open("tests/testdata/info_json_2_0/info_from_spec.json")
i.read(fh)
self.assertEqual(i.context, "http://iiif.io/api/image/2/context.json")
self.assertEqual(i.id, "http://www.example.org/image-service/abcd1234/1E34750D-38DB-4825-A38A-B60A345E591C")
self.assertEqual(i.protocol, "http://iiif.io/api/image")
self.assertEqual(i.width, 6000)
self.assertEqual(i.height, 4000)
self.assertEqual(
i.sizes, [{"width": 150, "height": 100}, {"width": 600, "height": 400}, {"width": 3000, "height": 2000}]
)
self.assertEqual(
i.profile,
[
"http://iiif.io/api/image/2/level2.json",
{
"formats": ["gif", "pdf"],
"qualities": ["color", "gray"],
"supports": [
"canonicalLinkHeader",
"rotationArbitrary",
"profileLinkHeader",
"http://example.com/feature/",
],
},
],
)
# extracted information
self.assertEqual(i.compliance, "http://iiif.io/api/image/2/level2.json")
示例2: test11_read_example_with_explicit_version
# 需要导入模块: from iiif.info import IIIFInfo [as 别名]
# 或者: from iiif.info.IIIFInfo import read [as 别名]
def test11_read_example_with_explicit_version(self):
i = IIIFInfo() #default not 1.1
fh = open('test_info/1.1/info_from_spec.json')
i.read(fh) #will get 1.1 from @context
self.assertEqual( i.api_version, '1.1' )
fh = open('test_info/1.1/info_from_spec.json')
self.assertRaises( Exception, i.read, fh, '0.1' ) # 0.1 bad
fh = open('test_info/1.1/info_from_spec.json')
i.read(fh, '1.1')
self.assertEqual( i.api_version, '1.1' )
示例3: test11_read_example_with_explicit_version
# 需要导入模块: from iiif.info import IIIFInfo [as 别名]
# 或者: from iiif.info.IIIFInfo import read [as 别名]
def test11_read_example_with_explicit_version(self):
"""Test reading without explicit version."""
i = IIIFInfo() # default not 1.1
fh = open('tests/testdata/info_json_1_1/info_from_spec.json')
i.read(fh) # will get 1.1 from @context
self.assertEqual(i.api_version, '1.1')
fh = open('tests/testdata/info_json_1_1/info_from_spec.json')
self.assertRaises(Exception, i.read, fh, '0.1') # 0.1 bad
fh = open('tests/testdata/info_json_1_1/info_from_spec.json')
i.read(fh, '1.1')
self.assertEqual(i.api_version, '1.1')
示例4: test10_read_example_from_spec
# 需要导入模块: from iiif.info import IIIFInfo [as 别名]
# 或者: from iiif.info.IIIFInfo import read [as 别名]
def test10_read_example_from_spec(self):
i = IIIFInfo(api_version='2.1')
fh = open('test_info/2.1/info_from_spec.json')
i.read(fh)
self.assertEqual( i.context, "http://iiif.io/api/image/2/context.json" )
self.assertEqual( i.id, "http://www.example.org/image-service/abcd1234/1E34750D-38DB-4825-A38A-B60A345E591C" )
self.assertEqual( i.protocol, "http://iiif.io/api/image" )
self.assertEqual( i.width, 6000 )
self.assertEqual( i.height, 4000 )
self.assertEqual( i.sizes, [ {"width" : 150, "height" : 100},
{"width" : 600, "height" : 400},
{"width" : 3000, "height": 2000} ] )
示例5: test10_read_example_from_spec
# 需要导入模块: from iiif.info import IIIFInfo [as 别名]
# 或者: from iiif.info.IIIFInfo import read [as 别名]
def test10_read_example_from_spec(self):
i = IIIFInfo(api_version='1.0')
fh = open('test_info/1.0/info_from_spec.json')
i.read(fh)
self.assertEqual( i.id, "1E34750D-38DB-4825-A38A-B60A345E591C" )
self.assertEqual( i.profile, "http://library.stanford.edu/iiif/image-api/compliance.html#level0" )
self.assertEqual( i.width, 6000 )
self.assertEqual( i.height, 4000 )
self.assertEqual( i.scale_factors, [1,2,4] )
self.assertEqual( i.tile_width, 1024 )
self.assertEqual( i.tile_height, 1024 )
self.assertEqual( i.formats, ['jpg','png'] )
self.assertEqual( i.qualities, ['native','grey'] )
示例6: test11_read_example_with_extra
# 需要导入模块: from iiif.info import IIIFInfo [as 别名]
# 或者: from iiif.info.IIIFInfo import read [as 别名]
def test11_read_example_with_extra(self):
i = IIIFInfo(api_version='2.1')
fh = open('test_info/2.1/info_with_extra.json')
i.read(fh)
self.assertEqual( i.context, "http://iiif.io/api/image/2/context.json" )
self.assertEqual( i.id, "http://www.example.org/image-service/abcd1234/1E34750D-38DB-4825-A38A-B60A345E591C" )
self.assertEqual( i.protocol, "http://iiif.io/api/image" )
self.assertEqual( i.width, 6000 )
self.assertEqual( i.height, 4000 )
self.assertEqual( i.tiles, [{"width" : 512, "scaleFactors" : [1,2,4,8,16]}] )
# and should have 1.1-like params too
self.assertEqual( i.tile_width, 512 )
self.assertEqual( i.scale_factors, [1,2,4,8,16] )
self.assertEqual( i.profile, "http://iiif.io/api/image/2/level2.json" )
示例7: test11_read_example_with_extra
# 需要导入模块: from iiif.info import IIIFInfo [as 别名]
# 或者: from iiif.info.IIIFInfo import read [as 别名]
def test11_read_example_with_extra(self):
"""Test reading of example with extra data."""
i = IIIFInfo()
fh = open("tests/testdata/info_json_2_0/info_with_extra.json")
i.read(fh)
self.assertEqual(i.context, "http://iiif.io/api/image/2/context.json")
self.assertEqual(i.id, "http://www.example.org/image-service/abcd1234/1E34750D-38DB-4825-A38A-B60A345E591C")
self.assertEqual(i.protocol, "http://iiif.io/api/image")
self.assertEqual(i.width, 6000)
self.assertEqual(i.height, 4000)
self.assertEqual(i.tiles, [{"width": 512, "scaleFactors": [1, 2, 4, 8, 16]}])
# and should have 1.1-like params too
self.assertEqual(i.tile_width, 512)
self.assertEqual(i.scale_factors, [1, 2, 4, 8, 16])
self.assertEqual(i.compliance, "http://iiif.io/api/image/2/level2.json")
示例8: test10_read_example_from_spec
# 需要导入模块: from iiif.info import IIIFInfo [as 别名]
# 或者: from iiif.info.IIIFInfo import read [as 别名]
def test10_read_example_from_spec(self):
"""Test read of example from spec."""
i = IIIFInfo(api_version='1.1')
fh = open('tests/testdata/info_json_1_1/info_from_spec.json')
i.read(fh)
self.assertEqual(
i.context, "http://library.stanford.edu/iiif/image-api/1.1/context.json")
self.assertEqual(
i.id, "http://iiif.example.com/prefix/1E34750D-38DB-4825-A38A-B60A345E591C")
self.assertEqual(
i.profile, "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0")
self.assertEqual(i.width, 6000)
self.assertEqual(i.height, 4000)
self.assertEqual(i.scale_factors, [1, 2, 4])
self.assertEqual(i.tile_width, 1024)
self.assertEqual(i.tile_height, 1024)
self.assertEqual(i.formats, ['jpg', 'png'])
self.assertEqual(i.qualities, ['native', 'grey'])
示例9: test07_read
# 需要导入模块: from iiif.info import IIIFInfo [as 别名]
# 或者: from iiif.info.IIIFInfo import read [as 别名]
def test07_read(self):
"""Read test."""
i = IIIFInfo()
fh = io.StringIO('{ "@id": "no_data" }')
i.read(fh, api_version="2.0")
self.assertEqual(i.api_version, "2.0")
fh = io.StringIO('{ "@id": "no_data" }')
self.assertRaises(IIIFInfoError, i.read, fh)
# missing identifier cases
fh = io.StringIO("{ }")
self.assertRaises(IIIFInfoError, i.read, fh, api_version="1.0")
fh = io.StringIO("{ }")
self.assertRaises(IIIFInfoError, i.read, fh, api_version="2.0")
# bad @context
fh = io.StringIO('{ "@context": "oops" }')
self.assertRaises(IIIFInfoError, i.read, fh)
#
fh = io.StringIO('{ "@context": "http://library.stanford.edu/' 'iiif/image-api/1.1/context.json", "@id": "a" }')
i.read(fh)
self.assertEqual(i.api_version, "1.1")
示例10: test10_read_examples_from_spec
# 需要导入模块: from iiif.info import IIIFInfo [as 别名]
# 或者: from iiif.info.IIIFInfo import read [as 别名]
def test10_read_examples_from_spec(self):
"""Test reading of examples from spec."""
# Section 5.2, full example
i = IIIFInfo(api_version='2.1')
fh = open('tests/testdata/info_json_2_1/info_from_spec_section_5_2.json')
i.read(fh)
self.assertEqual(i.context,
"http://iiif.io/api/image/2/context.json")
self.assertEqual(i.id,
"http://www.example.org/image-service/abcd1234/1E34750D-38DB-4825-A38A-B60A345E591C")
self.assertEqual(i.protocol, "http://iiif.io/api/image")
self.assertEqual(i.width, 6000)
self.assertEqual(i.height, 4000)
self.assertEqual(i.sizes, [{"width": 150, "height": 100},
{"width": 600, "height": 400},
{"width": 3000, "height": 2000}])
self.assertEqual(i.tiles, [{"width": 512,
"scaleFactors": [1, 2, 4, 8, 16]}])
self.assertEqual(i.profile,
["http://iiif.io/api/image/2/level2.json"])
# extracted information
self.assertEqual(i.compliance,
"http://iiif.io/api/image/2/level2.json")
# and 1.1 style tile properties
self.assertEqual(i.tile_width, 512)
self.assertEqual(i.tile_height, 512)
self.assertEqual(i.scale_factors, [1, 2, 4, 8, 16])
# Section 5.3, full example
i = IIIFInfo(api_version='2.1')
fh = open('tests/testdata/info_json_2_1/info_from_spec_section_5_3.json')
i.read(fh)
self.assertEqual(i.context,
"http://iiif.io/api/image/2/context.json")
self.assertEqual(i.id,
"http://www.example.org/image-service/abcd1234/1E34750D-38DB-4825-A38A-B60A345E591C")
self.assertEqual(i.protocol, "http://iiif.io/api/image")
self.assertEqual(i.width, 4000)
self.assertEqual(i.height, 3000)
self.assertEqual(
i.profile,
["http://iiif.io/api/image/2/level2.json",
{"formats": ["gif", "pdf"],
"maxWidth": 2000,
"qualities": ["color", "gray"],
"supports": ["canonicalLinkHeader", "rotationArbitrary",
"profileLinkHeader", "http://example.com/feature/"]}])
# extracted information
self.assertEqual(i.compliance,
"http://iiif.io/api/image/2/level2.json")
# Section 5.6, full example
i = IIIFInfo(api_version='2.1')
fh = open('tests/testdata/info_json_2_1/info_from_spec_section_5_6.json')
i.read(fh)
self.assertEqual(i.context,
"http://iiif.io/api/image/2/context.json")
self.assertEqual(i.id,
"http://www.example.org/image-service/abcd1234/1E34750D-38DB-4825-A38A-B60A345E591C")
self.assertEqual(i.protocol, "http://iiif.io/api/image")
self.assertEqual(i.width, 6000)
self.assertEqual(i.height, 4000)
self.assertEqual(i.sizes, [{"width": 150, "height": 100},
{"width": 600, "height": 400},
{"width": 3000, "height": 2000}])