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


Python request.IIIFRequest类代码示例

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


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

示例1: test08_parse_quality_bad

 def test08_parse_quality_bad(self):
     r = IIIFRequest()
     r.quality='does_not_exist'
     self.assertRaises( IIIFError, r.parse_quality )
     # bad ones
     r.quality=''
     self.assertRaises( IIIFError, r.parse_quality )
开发者ID:pbinkley,项目名称:iiif,代码行数:7,代码来源:test_request_2_0.py

示例2: test10_encode

 def test10_encode(self):
     for tname in sorted(data.iterkeys()):
         tdata=data[tname]
         print tname + "   " + self.pstr(data[tname][0]) + "  " + data[tname][1]
         iiif = IIIFRequest(**data[tname][0])
         self.assertEqual(iiif.url(),data[tname][1])
     print
开发者ID:pbinkley,项目名称:iiif,代码行数:7,代码来源:test_request_2_0.py

示例3: test08_parse_quality_bad

 def test08_parse_quality_bad(self):
     r = IIIFRequest(api_version="1.1")
     r.quality = "does_not_exist"
     self.assertRaises(IIIFError, r.parse_quality)
     # bad ones
     r.quality = ""
     self.assertRaises(IIIFError, r.parse_quality)
开发者ID:pbinkley,项目名称:iiif,代码行数:7,代码来源:test_request_1_1.py

示例4: test08_parse_quality_bad

 def test08_parse_quality_bad(self):
     """Parse quality - bad requests."""
     r = IIIFRequest(api_version='2.1')
     r.quality = 'does_not_exist'
     self.assertRaises(IIIFError, r.parse_quality)
     # bad ones
     r.quality = ''
     self.assertRaises(IIIFError, r.parse_quality)
开发者ID:edsilv,项目名称:iiif,代码行数:8,代码来源:test_request_2_1.py

示例5: test1_encode

 def test1_encode(self):
     print "Encoding tests..."
     for tname in sorted(data.iterkeys()):
         tdata=data[tname]
         print tname + "   " + self.pstr(data[tname][0]) + "  " + data[tname][1]
         iiif = IIIFRequest(api_version='1.0',**data[tname][0])
         self.assertEqual(iiif.url(),data[tname][1])
     print
开发者ID:pbinkley,项目名称:iiif,代码行数:8,代码来源:test_request_spec_1_0.py

示例6: test02_parse_non_negative_int

 def test02_parse_non_negative_int(self):
     """Test parsing of non-negative integer."""
     r = IIIFRequest()
     self.assertEqual(r._parse_non_negative_int('1', 'a'), (1))
     self.assertRaises(ValueError,
                       r._parse_non_negative_int, 'a', 'region')
     self.assertRaises(ValueError,
                       r._parse_non_negative_int, '-1', 'region')
开发者ID:edsilv,项目名称:iiif,代码行数:8,代码来源:test_request_common.py

示例7: test02_parse_region_bad

 def test02_parse_region_bad(self):
     r = IIIFRequest()
     r.region='pct:0,0,50,1000'
     self.assertRaises( IIIFError, r.parse_region )
     r.region='pct:-10,0,50,100'
     self.assertRaises( IIIFError, r.parse_region )
     r.region='square'
     self.assertRaises( IIIFError, r.parse_region )
开发者ID:pbinkley,项目名称:iiif,代码行数:8,代码来源:test_request_2_0.py

示例8: test02_parse_region_bad

 def test02_parse_region_bad(self):
     r = IIIFRequest(api_version="1.1")
     r.region = "pct:0,0,50,1000"
     self.assertRaises(IIIFError, r.parse_region)
     r.region = "pct:-10,0,50,100"
     self.assertRaises(IIIFError, r.parse_region)
     r.region = "square"
     self.assertRaises(IIIFError, r.parse_region)
开发者ID:pbinkley,项目名称:iiif,代码行数:8,代码来源:test_request_1_1.py

示例9: test02_parse_region_bad

 def test02_parse_region_bad(self):
     """Bad regions."""
     r = IIIFRequest(api_version='2.0')
     r.region = 'pct:0,0,50,1000'
     self.assertRaises(IIIFError, r.parse_region)
     r.region = 'pct:-10,0,50,100'
     self.assertRaises(IIIFError, r.parse_region)
     r.region = 'square'
     self.assertRaises(IIIFError, r.parse_region)
开发者ID:edsilv,项目名称:iiif,代码行数:9,代码来源:test_request_2_0.py

示例10: test18_url

 def test18_url(self):
     r = IIIFRequest()
     r.size = None 
     r.size_wh = [11,22]
     self.assertEqual( r.url(identifier='abc1'), 'abc1/full/11,22/0/default' )
     r.size_wh = [100,None]
     self.assertEqual( r.url(identifier='abc2'), 'abc2/full/100,/0/default' )
     r.size_wh = [None,999]
     self.assertEqual( r.url(identifier='abc3'), 'abc3/full/,999/0/default' )
     r.size_wh = None
     self.assertEqual( r.url(identifier='abc4'), 'abc4/full/full/0/default' )
开发者ID:pbinkley,项目名称:iiif,代码行数:11,代码来源:test_request_2_1.py

示例11: check_encoding

    def check_encoding(self, data, api_version):
        """Encoding.

        Checks that every for each test in the dict data,
        the data values (first element) encode to the URL
        given (second element).
        """
        for tname in sorted(data.keys()):
            tdata = data[tname]
            iiif = IIIFRequest(api_version=api_version, **data[tname][0])
            self.assertEqual(iiif.url(), data[tname][1])
开发者ID:edsilv,项目名称:iiif,代码行数:11,代码来源:request.py

示例12: test09_parse_format

 def test09_parse_format(self):
     """Test parse_format."""
     r = IIIFRequest(api_version='2.1')
     r.format = 'jpg'
     r.parse_format()
     r.format = 'something_else_Z134'
     r.parse_format()
     # Bad things
     r.format = 'no spaces allowed'
     self.assertRaises(IIIFRequestError, r.parse_format)
     r.format = '~'
     self.assertRaises(IIIFRequestError, r.parse_format)
     r.format = ''
     self.assertRaises(IIIFRequestError, r.parse_format)
开发者ID:edsilv,项目名称:iiif,代码行数:14,代码来源:test_request_2_1.py

示例13: __init__

    def __init__(self, prefix, identifier, config, klass, auth):
        """Initialize IIIFHandler setting key configurations.

        Positional parameters:
        prefix -- URI prefix (without leading or trailing slashes)
        identifier -- identifier of image
        config -- instance of Config class
        klass -- IIIFManipulator sub-class to do manipulations
        auth -- IIIFAuth sub-class instance for auth or None
        """
        self.prefix = prefix
        self.identifier = identifier
        self.config = config
        self.klass = klass
        self.api_version = config.api_version
        self.auth = auth
        self.degraded = False
        self.logger = logging.getLogger('IIIFHandler')
        #
        # Create objects to process request
        self.iiif = IIIFRequest(api_version=self.api_version,
                                identifier=self.identifier)
        self.manipulator = klass(api_version=self.api_version)
        #
        # Set up auth object with locations if not already done
        if (self.auth and not self.auth.login_uri):
            self.auth.login_uri = self.server_and_prefix + '/login'
            if (self.auth.logout_handler is not None):
                self.auth.logout_uri = self.server_and_prefix + '/logout'
            self.auth.access_token_uri = self.server_and_prefix + '/token'
        #
        # Response headers
        # -- All responses should have CORS header
        self.headers = {'Access-control-allow-origin': '*'}
开发者ID:zimeon,项目名称:iiif,代码行数:34,代码来源:flask_utils.py

示例14: test12_decode_good

 def test12_decode_good(self):
     """Decoding examples that should work."""
     r = IIIFRequest(api_version='2.1', baseurl='1.1_netpbm/a/')
     r.split_url('1.1_netpbm/a/b/full/full/0/default')
     self.assertEqual(r.identifier, 'b')
     # id with slashes in it
     r = IIIFRequest(api_version='2.1', allow_slashes_in_identifier=True)
     r.split_url('a/b/c/full/full/0/default')
     self.assertFalse(r.info)
     self.assertEqual(r.identifier, 'a/b/c')
     r = IIIFRequest(api_version='2.1', allow_slashes_in_identifier=True)
     r.split_url('a/b/info.json')
     self.assertTrue(r.info)
     self.assertEqual(r.identifier, 'a/b')
开发者ID:edsilv,项目名称:iiif,代码行数:14,代码来源:test_request_2_1.py

示例15: test02_derive

 def test02_derive(self):
     m = IIIFManipulator()
     r = IIIFRequest()
     r.parse_url('id1/full/full/0/default')
     tmp = tempfile.mkdtemp()
     outfile = os.path.join(tmp,'testout.png')
     try:
         m.derive(srcfile='testimages/test1.png',
                  request=r, outfile=outfile);
         self.assertTrue( os.path.isfile(outfile) )
         self.assertEqual( os.path.getsize(outfile), 65810 )
     finally:
         shutil.rmtree(tmp) 
     # and where path to outfile must be created
     outfile = os.path.join(tmp,'a','b','testout.png')
     try:
         m.derive(srcfile='testimages/test1.png',
                  request=r, outfile=outfile);
         self.assertTrue( os.path.isfile(outfile) )
         self.assertEqual( os.path.getsize(outfile), 65810 )
     finally:
         shutil.rmtree(tmp) 
开发者ID:edsu,项目名称:iiif,代码行数:22,代码来源:test_manipulator.py


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