本文整理汇总了Python中safe.metadata.ImpactLayerMetadata.get_xml_value方法的典型用法代码示例。如果您正苦于以下问题:Python ImpactLayerMetadata.get_xml_value方法的具体用法?Python ImpactLayerMetadata.get_xml_value怎么用?Python ImpactLayerMetadata.get_xml_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类safe.metadata.ImpactLayerMetadata
的用法示例。
在下文中一共展示了ImpactLayerMetadata.get_xml_value方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_metadata_date
# 需要导入模块: from safe.metadata import ImpactLayerMetadata [as 别名]
# 或者: from safe.metadata.ImpactLayerMetadata import get_xml_value [as 别名]
def test_metadata_date(self):
metadata = ImpactLayerMetadata('random_layer_id')
path = TEST_XML_BASEPATH + 'gco:Date'
# using QDate
test_value = QDate(2015, 6, 7)
metadata.set('ISO19115_TEST', test_value, path)
self.assertEqual(metadata.get_xml_value('ISO19115_TEST'), '2015-06-07')
# using datetime
test_value = datetime(2015, 6, 7)
metadata.update('ISO19115_TEST', test_value)
self.assertEqual(metadata.get_xml_value('ISO19115_TEST'), '2015-06-07')
# using date
test_value = date(2015, 6, 7)
metadata.set('ISO19115_TEST', test_value, path)
self.assertEqual(metadata.get_xml_value('ISO19115_TEST'), '2015-06-07')
# using str should fail
test_value = '2015-06-07'
with self.assertRaises(TypeError):
metadata.update('ISO19115_TEST', test_value)
示例2: test_metadata_str
# 需要导入模块: from safe.metadata import ImpactLayerMetadata [as 别名]
# 或者: from safe.metadata.ImpactLayerMetadata import get_xml_value [as 别名]
def test_metadata_str(self):
metadata = ImpactLayerMetadata('random_layer_id')
path = TEST_XML_BASEPATH + 'gco:CharacterString'
# using str
test_value = 'Random string'
metadata.set('ISO19115_TEST', test_value, path)
self.assertEqual(
metadata.get_xml_value('ISO19115_TEST'), 'Random string')
# using int
test_value = 1234
metadata.update('ISO19115_TEST', test_value)
self.assertEqual(metadata.get_xml_value('ISO19115_TEST'), '1234')
# using float
test_value = 1234.5678
metadata.update('ISO19115_TEST', test_value)
self.assertEqual(metadata.get_xml_value('ISO19115_TEST'), '1234.5678')
# using invalid QUrl
test_value = QUrl()
with self.assertRaises(TypeError):
metadata.update('ISO19115_TEST', test_value)
示例3: test_metadata_url
# 需要导入模块: from safe.metadata import ImpactLayerMetadata [as 别名]
# 或者: from safe.metadata.ImpactLayerMetadata import get_xml_value [as 别名]
def test_metadata_url(self):
metadata = ImpactLayerMetadata('random_layer_id')
path = TEST_XML_BASEPATH + 'gmd:URL'
# using QUrl
test_value = QUrl('http://inasafe.org')
metadata.set('ISO19115_TEST', test_value, path)
self.assertEqual(
metadata.get_xml_value('ISO19115_TEST'), 'http://inasafe.org')
# using str should work as it is casted
test_value = 'http://inasafe.org'
metadata.update('ISO19115_TEST', test_value)
# using invalid QUrl (has a space)
test_value = QUrl('http://inasafe.org ')
with self.assertRaises(ValueError):
metadata.set('ISO19115_TEST', test_value, path)
示例4: test_xml_read
# 需要导入模块: from safe.metadata import ImpactLayerMetadata [as 别名]
# 或者: from safe.metadata.ImpactLayerMetadata import get_xml_value [as 别名]
def test_xml_read(self):
generated_metadata = ImpactLayerMetadata(
EXISTING_IMPACT_FILE, xml_uri=EXISTING_IMPACT_XML)
# TODO (MB): add more checks
self.assertEquals(generated_metadata.get_xml_value('license'), 'GPLv2')