本文整理汇总了Python中iiif.request.IIIFRequest.baseurl方法的典型用法代码示例。如果您正苦于以下问题:Python IIIFRequest.baseurl方法的具体用法?Python IIIFRequest.baseurl怎么用?Python IIIFRequest.baseurl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iiif.request.IIIFRequest
的用法示例。
在下文中一共展示了IIIFRequest.baseurl方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test01_split_url
# 需要导入模块: from iiif.request import IIIFRequest [as 别名]
# 或者: from iiif.request.IIIFRequest import baseurl [as 别名]
def test01_split_url(self):
"""Test split_url() method.
For everything except the handling of extension type on
info.json requests (where v1.0 allows XML), the behavior
of split_url() is version independent.
"""
# mismatching baseurl
r = IIIFRequest()
r.baseurl = 'http://ex.org/a/'
self.assertRaises(IIIFRequestError, r.split_url, 'http://other.base.url/')
# matching baseurl, but bad request
r = IIIFRequest()
r.baseurl = 'http://ex.org/a/'
self.assertRaises(IIIFRequestBaseURI, r.split_url, 'http://ex.org/a/b')
# matching baseurl, good request
r = IIIFRequest(baseurl='http://ex.org/a/')
r.identifier = None
r.split_url('http://ex.org/a/b/full/full/0/native')
self.assertEqual(r.identifier, 'b')
self.assertEqual(r.region, 'full')
self.assertEqual(r.size, 'full')
# matching baseurl, insert id, good request
r = IIIFRequest(baseurl='http://ex.org/a/')
r.identifier = 'b'
r.split_url('http://ex.org/a/full/full/0/native')
self.assertEqual(r.identifier, 'b')
self.assertEqual(r.region, 'full')
self.assertEqual(r.size, 'full')
# matching baseurl, too many segments
r = IIIFRequest(baseurl='http://ex.org/a/')
self.assertRaises(IIIFRequestError, r.split_url,
'http://ex.org/a/1/2/3/4/5/6')
示例2: test19_split_url
# 需要导入模块: from iiif.request import IIIFRequest [as 别名]
# 或者: from iiif.request.IIIFRequest import baseurl [as 别名]
def test19_split_url(self):
"""Test split_url() method.
Most parts are common to all versions, except handling
of info.json extensions.
"""
# api_version=1.0, format=xyz -> bad
r = IIIFRequest(api_version='1.0')
r.baseurl = 'http://ex.org/a/'
self.assertRaises(IIIFError, r.split_url,
'http://ex.org/a/b/info.xyz')
# api_version=2.1, format=xml -> bad
r = IIIFRequest(api_version='2.1')
r.baseurl = 'http://ex.org/a/'
self.assertRaises(IIIFError, r.split_url,
'http://ex.org/a/b/info.xml')
# api_version=2.1, format=xyz -> bad
r = IIIFRequest(api_version='2.1')
r.baseurl = 'http://ex.org/a/'
self.assertRaises(IIIFError, r.split_url,
'http://ex.org/a/b/info.xyz')
示例3: test19_split_url
# 需要导入模块: from iiif.request import IIIFRequest [as 别名]
# 或者: from iiif.request.IIIFRequest import baseurl [as 别名]
def test19_split_url(self):
# mismatching baseurl
r = IIIFRequest()
r.baseurl = 'http://ex.org/a/'
self.assertRaises( IIIFError, r.split_url, 'http://other.base.url/' )
# matching baseurl, but bad request
r = IIIFRequest()
r.baseurl = 'http://ex.org/a/'
self.assertRaises( IIIFRequestBaseURI , r.split_url, 'http://ex.org/a/b' )
# matching baseurl, good request
r = IIIFRequest()
r.baseurl = 'http://ex.org/a/'
r.identifier = None
r.split_url('http://ex.org/a/b/full/full/0/native')
self.assertEqual( r.identifier, 'b' )
self.assertEqual( r.region, 'full' )
self.assertEqual( r.size, 'full' )
# matching baseurl, insert id, good request
r = IIIFRequest()
r.baseurl = 'http://ex.org/a/'
r.identifier = 'b'
r.split_url('http://ex.org/a/full/full/0/native')
self.assertEqual( r.identifier, 'b' )
self.assertEqual( r.region, 'full' )
self.assertEqual( r.size, 'full' )
# matching baseurl, too many segments
r = IIIFRequest()
r.baseurl = 'http://ex.org/a/'
self.assertRaises( IIIFError, r.split_url, 'http://ex.org/a/1/2/3/4/5/6' )
# api_version=1.0, format=xyz -> bad
r = IIIFRequest(api_version='1.0')
r.baseurl = 'http://ex.org/a/'
self.assertRaises( IIIFError, r.split_url, 'http://ex.org/a/b/info.xyz' )
# api_version=2.1, format=xml -> bad
r = IIIFRequest(api_version='2.1')
r.baseurl = 'http://ex.org/a/'
self.assertRaises( IIIFError, r.split_url, 'http://ex.org/a/b/info.xml' )
# api_version=2.1, format=xyz -> bad
r = IIIFRequest(api_version='2.1')
r.baseurl = 'http://ex.org/a/'
self.assertRaises( IIIFError, r.split_url, 'http://ex.org/a/b/info.xyz' )
示例4: test03_str
# 需要导入模块: from iiif.request import IIIFRequest [as 别名]
# 或者: from iiif.request.IIIFRequest import baseurl [as 别名]
def test03_str(self):
"""Simple tests of str() method."""
r = IIIFRequest()
r.baseurl = 'http://ex.org/'
r.identifier = 'abc'
# info
r.info = True
r.format = 'json'
self.assertTrue(re.search(r'INFO request', str(r)))
self.assertTrue(re.search(r'format=json', str(r)))
# non-info
r.info = False
r.region = 'R'
r.size = 'S'
r.rotation = 'X'
r.quality = 'Q'
r.format = 'jpg'
self.assertFalse(re.search(r'INFO request', str(r)))
self.assertTrue(re.search(r'region=R', str(r)))
self.assertTrue(re.search(r'format=jpg', str(r)))