safe.storage.metadata_utilities module

InaSAFE Disaster risk assessment tool developed by AusAid - Exception Classes.

Custom exception classes for the IS application.

Contact : ole.moller.nielsen@gmail.com

Note

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

safe.storage.metadata_utilities.CDATA(text=None)[source]
safe.storage.metadata_utilities.generate_iso_metadata(keywords=None)[source]

Make a valid ISO 19115 XML using the values of safe.get_defaults

This method will create XML based on the iso_19115_template.py template The $placeholders there will be replaced by the values returned from safe.defaults.get_defaults. Note that get_defaults takes care of using the values set in QGIS settings if available.

Parameters:keywords (dict) – The metadata keywords to write (which should be provided as a dict of key value pairs).
Returns:str valid XML
safe.storage.metadata_utilities.read_iso_metadata(keyword_filename)[source]

Try to extract keywords from an xml file

Parameters:keyword_filename (str) – Name of keywords file.
Returns:metadata: a dictionary containing the metadata. the keywords element contains the content of the ISO_METADATA_KW_TAG as list so that it can be read line per line as if it was a file.
Raises:ReadMetadataError, IOError
safe.storage.metadata_utilities.valid_iso_xml(xml_filename)[source]

add the necessary tags into an existing xml file or create a new one

Parameters:xml_filename – name of the xml file
Returns:tree the parsed ElementTree
safe.storage.metadata_utilities.write_iso_metadata_file(xml_filename, keywords=None)[source]

Make a valid ISO 19115 XML file using the values of safe.get_defaults

This method will create a file based on the iso_19115_template.py template The $placeholders there will be replaced by the values returned from safe.defaults.get_defaults. Note that get_defaults takes care of using the values set in QGIS settings if available.

Parameters:xml_filename – full path to the file to be generated
Returns:
safe.storage.metadata_utilities.write_keyword_in_iso_metadata(keyword_filename)[source]

Write keywords in an xml file at the same location as the keyword file

Parameters:keyword_filename (str) – Name of keywords file.
Returns:xml_filename: the path of the xml file
Raises:ReadMetadataError