本文整理汇总了Python中obspy.core.event.ResourceIdentifier.set_referred_object方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceIdentifier.set_referred_object方法的具体用法?Python ResourceIdentifier.set_referred_object怎么用?Python ResourceIdentifier.set_referred_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.event.ResourceIdentifier
的用法示例。
在下文中一共展示了ResourceIdentifier.set_referred_object方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _set_resource_id
# 需要导入模块: from obspy.core.event import ResourceIdentifier [as 别名]
# 或者: from obspy.core.event.ResourceIdentifier import set_referred_object [as 别名]
def _set_resource_id(self, value):
if isinstance(value, dict):
value = ResourceIdentifier(**value)
elif type(value) != ResourceIdentifier:
value = ResourceIdentifier(value)
value.set_referred_object(self, warn=False)
self.__dict__['resource_id'] = value
示例2: test_adding_a_referred_object_after_creation
# 需要导入模块: from obspy.core.event import ResourceIdentifier [as 别名]
# 或者: from obspy.core.event.ResourceIdentifier import set_referred_object [as 别名]
def test_adding_a_referred_object_after_creation(self):
"""
Check that the referred objects can also be made available after the
ResourceIdentifier instances have been created.
"""
obj = UTCDateTime()
res_id = "obspy.org/time/test"
ref_a = ResourceIdentifier(res_id)
ref_b = ResourceIdentifier(res_id)
ref_c = ResourceIdentifier(res_id)
# All three will have no resource attached.
self.assertEqual(ref_a.get_referred_object(), None)
self.assertEqual(ref_b.get_referred_object(), None)
self.assertEqual(ref_c.get_referred_object(), None)
# Setting the object for one will make it available to all other
# instances, provided they weren't bound to specific objects.
ref_b.set_referred_object(obj)
self.assertIs(ref_a.get_referred_object(), obj)
self.assertIs(ref_b.get_referred_object(), obj)
self.assertIs(ref_c.get_referred_object(), obj)