本文整理汇总了Python中omero.gateway.utils.ServiceOptsDict.get方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceOptsDict.get方法的具体用法?Python ServiceOptsDict.get怎么用?Python ServiceOptsDict.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类omero.gateway.utils.ServiceOptsDict
的用法示例。
在下文中一共展示了ServiceOptsDict.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_setitem
# 需要导入模块: from omero.gateway.utils import ServiceOptsDict [as 别名]
# 或者: from omero.gateway.utils.ServiceOptsDict import get [as 别名]
def test_setitem(self):
# string
d = ServiceOptsDict({"omero.share": "2", "omero.user": "1"})
d["omero.group"] = "-1"
# unicode
d = ServiceOptsDict({"omero.share": u'2', "omero.user": u'1'})
d["omero.group"] = u'-1'
# int
d = ServiceOptsDict({"omero.share": 1, "omero.user": 2})
d["omero.group"] = -1
# long
import sys
maxint = sys.maxint
d = ServiceOptsDict({"omero.group": (maxint + 1)})
d["omero.user"] = (maxint + 1)
# Setter passed None as value remove from internal dict
d = ServiceOptsDict({"omero.share": "2", "omero.user": "1"})
assert d.get("omero.share") is not None
d.setOmeroShare()
assert d.get("omero.share") is None
assert d.get("omero.user") is not None
d.setOmeroUser()
assert d.get("omero.user") is None
try:
d = ServiceOptsDict({"omero.group": True})
d["omero.user"] = True
except:
pass
else:
self.fail("AttributeError: ServiceOptsDict argument must be a"
" string, unicode or numeric type")
try:
d = ServiceOptsDict({"omero.group": []})
d["omero.user"] = []
except:
pass
else:
self.fail("AttributeError: ServiceOptsDict argument must be a"
" string, unicode or numeric type")
try:
d = ServiceOptsDict({"omero.group": {}})
d["omero.user"] = {}
except:
pass
else:
self.fail("AttributeError: ServiceOptsDict argument must be a"
" string, unicode or numeric type")
示例2: test_getitem
# 需要导入模块: from omero.gateway.utils import ServiceOptsDict [as 别名]
# 或者: from omero.gateway.utils.ServiceOptsDict import get [as 别名]
def test_getitem(self):
d = ServiceOptsDict({"omero.group":-1, "omero.user": 1})
assert d["omero.group"] == "-1"
assert d["omero.user"] == "1"
d["omero.share"] = 2
d["foo"] = "bar"
assert d["omero.share"] == "2"
assert d["foo"] == "bar"
del d["omero.user"]
assert d == {"omero.group": "-1", 'foo': 'bar', "omero.share": "2"}
pytest.raises(TypeError, d.__getitem__)
assert d.get("omero.user") == None
assert d.get("omero.user", "5"), "5"
示例3: test_constructor
# 需要导入模块: from omero.gateway.utils import ServiceOptsDict [as 别名]
# 或者: from omero.gateway.utils.ServiceOptsDict import get [as 别名]
def test_constructor(self):
assert ServiceOptsDict() == {}
assert ServiceOptsDict() is not {}
assert ServiceOptsDict() is not dict()
d = {"omero.group":-1}
d = ServiceOptsDict(d)
resd = d.get("omero.group")
assert isinstance(resd, str)
assert d.get("omero.group") == str(d["omero.group"])
d = ServiceOptsDict(x=1,y=2)
assert d.get("x") == "1"
assert d.get("y") == "2"
# ServiceOptsDict can be passed initializing data, but it needs to be a dict
pytest.raises(AttributeError, ServiceOptsDict, kwargs={"data":"data"})
s = ServiceOptsDict(data={'option':'a'})
示例4: test_constructor
# 需要导入模块: from omero.gateway.utils import ServiceOptsDict [as 别名]
# 或者: from omero.gateway.utils.ServiceOptsDict import get [as 别名]
def test_constructor(self):
self.assertEqual(ServiceOptsDict(), {})
self.assert_(ServiceOptsDict() is not {})
self.assert_(ServiceOptsDict() is not dict())
d = {"omero.group":-1}
d = ServiceOptsDict(d)
resd = d.get("omero.group")
self.assert_(isinstance(resd, str))
self.assertEqual(d.get("omero.group"), str(d["omero.group"]))
d = ServiceOptsDict(x=1,y=2)
self.assertEqual(d.get("x"), "1")
self.assertEqual(d.get("y"), "2")
# ServiceOptsDict can be passed initializing data, but it needs to be a dict
self.assertRaises(AttributeError, ServiceOptsDict, kwargs={"data":"data"})
s = ServiceOptsDict(data={'option':'a'})
示例5: test_setter_an_getter
# 需要导入模块: from omero.gateway.utils import ServiceOptsDict [as 别名]
# 或者: from omero.gateway.utils.ServiceOptsDict import get [as 别名]
def test_setter_an_getter(self):
group = -1
user = 1
share = 2
d = ServiceOptsDict()
d.set("omero.group", group)
assert d.get("omero.group") == d.getOmeroGroup()
d.setOmeroGroup(group)
assert d.get("omero.group") == d.getOmeroGroup()
d.set("omero.user", user)
assert d.get("omero.user") == d.getOmeroUser()
d.setOmeroUser(user)
assert d.get("omero.user") == d.getOmeroUser()
d.set("omero.share", share)
assert d.get("omero.share") == d.getOmeroShare()
d.setOmeroShare(share)
assert d.get("omero.share") == d.getOmeroShare()