当前位置: 首页>>代码示例>>Python>>正文


Python IIIFInfo.read方法代码示例

本文整理汇总了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")
开发者ID:edsilv,项目名称:iiif,代码行数:33,代码来源:test_info_2_0.py

示例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' )
开发者ID:pbinkley,项目名称:iiif,代码行数:12,代码来源:test_info_1_1.py

示例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')
开发者ID:edsilv,项目名称:iiif,代码行数:13,代码来源:test_info_1_1.py

示例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} ] )
开发者ID:pbinkley,项目名称:iiif,代码行数:14,代码来源:test_info_2_1.py

示例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'] )
开发者ID:pbinkley,项目名称:iiif,代码行数:15,代码来源:test_info_1_0.py

示例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" )
开发者ID:pbinkley,项目名称:iiif,代码行数:16,代码来源:test_info_2_1.py

示例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")
开发者ID:edsilv,项目名称:iiif,代码行数:17,代码来源:test_info_2_0.py

示例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'])
开发者ID:edsilv,项目名称:iiif,代码行数:20,代码来源:test_info_1_1.py

示例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")
开发者ID:edsilv,项目名称:iiif,代码行数:22,代码来源:test_info_common.py

示例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}])
开发者ID:edsilv,项目名称:iiif,代码行数:67,代码来源:test_info_2_1.py


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