本文整理匯總了Python中iiif.info.IIIFInfo.compliance方法的典型用法代碼示例。如果您正苦於以下問題:Python IIIFInfo.compliance方法的具體用法?Python IIIFInfo.compliance怎麽用?Python IIIFInfo.compliance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iiif.info.IIIFInfo
的用法示例。
在下文中一共展示了IIIFInfo.compliance方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test03_level
# 需要導入模塊: from iiif.info import IIIFInfo [as 別名]
# 或者: from iiif.info.IIIFInfo import compliance [as 別名]
def test03_level(self):
"""Test level handling."""
i = IIIFInfo()
i.compliance_prefix = "prefix/"
i.compliance_suffix = "/suffix"
# and good
i.compliance = "prefix/2/suffix"
self.assertEqual(i.level, 2)
i.compliance = "prefix/3/suffix"
self.assertEqual(i.level, 3)
# and bad
i.compliance = ""
# FIXME: how to avoid wrapping @property call in lamda?
self.assertRaises(IIIFInfoError, lambda: i.level)
i.compliance = "prefix//suffix"
self.assertRaises(IIIFInfoError, lambda: i.level)
i.compliance = "prefix/22/suffix"
self.assertRaises(IIIFInfoError, lambda: i.level)
i.compliance = "prefix/junk/suffix"
self.assertRaises(IIIFInfoError, lambda: i.level)
i.compliance = "extra/prefix/2/suffix"
self.assertRaises(IIIFInfoError, lambda: i.level)
i.compliance = "...2/suffix"
self.assertRaises(IIIFInfoError, lambda: i.level)
i.compliance = "prefix/2..."
self.assertRaises(IIIFInfoError, lambda: i.level)
i.compliance = "prefix/2/suffix/extra"
self.assertRaises(IIIFInfoError, lambda: i.level)
示例2: test05_level_and_profile
# 需要導入模塊: from iiif.info import IIIFInfo [as 別名]
# 或者: from iiif.info.IIIFInfo import compliance [as 別名]
def test05_level_and_profile(self):
"""Test level and profile setting."""
i = IIIFInfo(api_version='2.1')
i.level = 0
self.assertEqual(i.level, 0)
self.assertEqual(i.compliance, "http://iiif.io/api/image/2/level0.json")
i.level = 2
self.assertEqual(i.level, 2)
self.assertEqual(i.compliance, "http://iiif.io/api/image/2/level2.json")
# Set via compliance
i.compliance = "http://iiif.io/api/image/2/level1.json"
self.assertEqual(i.level, 1)
# Set via profile
i.profile = ["http://iiif.io/api/image/2/level1.json"]
self.assertEqual(i.level, 1)
# Set new via compliance
i = IIIFInfo(api_version='2.1')
i.compliance = "http://iiif.io/api/image/2/level1.json"
self.assertEqual(i.level, 1)