本文整理汇总了Python中obspy.core.event.ResourceIdentifier.get_quakeml_uri方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceIdentifier.get_quakeml_uri方法的具体用法?Python ResourceIdentifier.get_quakeml_uri怎么用?Python ResourceIdentifier.get_quakeml_uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.event.ResourceIdentifier
的用法示例。
在下文中一共展示了ResourceIdentifier.get_quakeml_uri方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_quakeml_regex
# 需要导入模块: from obspy.core.event import ResourceIdentifier [as 别名]
# 或者: from obspy.core.event.ResourceIdentifier import get_quakeml_uri [as 别名]
def test_quakeml_regex(self):
"""
Tests that regex used to check for QuakeML validatity actually works.
"""
# This one contains all valid characters. It should pass the
# validation.
res_id = (
"smi:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
"1234567890-.*()_~'/abcdefghijklmnopqrstuvwxyzABCDEFGHIKLMNOPQR"
"STUVWXYZ0123456789-.*()_~'+?=,;&")
res = ResourceIdentifier(res_id)
self.assertEqual(res_id, res.get_quakeml_uri())
# The id has to valid from start to end. Due to the spaces this cannot
# automatically be converted to a correct one.
res_id = ("something_before smi:local/something something_after")
res = ResourceIdentifier(res_id)
self.assertRaises(ValueError, res.get_quakeml_uri)
# A colon is an invalid character.
res_id = ("smi:local/hello:yea")
res = ResourceIdentifier(res_id)
self.assertRaises(ValueError, res.get_quakeml_uri)
# Space as well
res_id = ("smi:local/hello yea")
res = ResourceIdentifier(res_id)
self.assertRaises(ValueError, res.get_quakeml_uri)
# Dots are fine
res_id = ("smi:local/hello....yea")
res = ResourceIdentifier(res_id)
self.assertEqual(res_id, res.get_quakeml_uri())
# Hats not
res_id = ("smi:local/hello^^yea")
res = ResourceIdentifier(res_id)
self.assertRaises(ValueError, res.get_quakeml_uri)
示例2: test_resource_id_valid_quakemluri
# 需要导入模块: from obspy.core.event import ResourceIdentifier [as 别名]
# 或者: from obspy.core.event.ResourceIdentifier import get_quakeml_uri [as 别名]
def test_resource_id_valid_quakemluri(self):
"""
Test that a resource identifier per default (i.e. no arguments to
__init__()) gets set up with a QUAKEML conform ID.
"""
rid = ResourceIdentifier()
self.assertEqual(rid.id, rid.get_quakeml_uri())
示例3: test_error_message_for_failing_quakeml_id_conversion
# 需要导入模块: from obspy.core.event import ResourceIdentifier [as 别名]
# 或者: from obspy.core.event.ResourceIdentifier import get_quakeml_uri [as 别名]
def test_error_message_for_failing_quakeml_id_conversion(self):
"""
Converting an id to a QuakeML compatible id might fail. Test the
error message.
"""
invalid_id = "http://example.org"
rid = ResourceIdentifier(invalid_id)
with self.assertRaises(ValueError) as e:
rid.get_quakeml_uri()
self.assertEqual(
e.exception.args[0],
"The id 'http://example.org' is not a valid QuakeML resource "
"identifier. ObsPy tried modifying it to "
"'smi:local/http://example.org' but it is still not valid. Please "
"make sure all resource ids are either valid or can be made valid "
"by prefixing them with 'smi:<authority_id>/'. Valid ids are "
"specified in the QuakeML manual section 3.1 and in particular "
"exclude colons for the final part.")