# Path: safe/definitions/versions.py

# 
# Path: safe/definitions/layer_purposes.py



import sys
import os
import qgis  # NOQA pylint: disable=unused-import
from functools import partial
from distutils.version import StrictVersion
from qgis.core import (
    QgsRectangle,
    QgsRasterLayer,
    QgsMapLayer,
    QgsExpression,
    QgsProject,
)
from qgis.PyQt.QtCore import QCoreApplication, Qt
from qgis.PyQt.QtWidgets import (
    QAction,
    QApplication,
    QToolButton,
    QMenu,
    QLineEdit,
    QInputDialog
)
from qgis.PyQt.QtGui import QIcon
from safe.common.custom_logging import LOGGER
from safe.utilities.expressions import qgis_expressions
from safe.definitions.versions import inasafe_release_status, inasafe_version
from safe.common.exceptions import (
    KeywordNotFoundError,
    NoKeywordsFoundError,
    MetadataReadError,
)
from safe.common.signals import send_static_message
from safe.utilities.resources import resources_path
from safe.utilities.gis import is_raster_layer
from safe.definitions.layer_purposes import (
    layer_purpose_exposure, layer_purpose_hazard
)
from safe.definitions.utilities import get_field_groups
from safe.utilities.i18n import tr
from safe.utilities.keyword_io import KeywordIO
from safe.utilities.utilities import is_keyword_version_supported
from safe.utilities.settings import setting, set_setting
        from safe.gui.widgets.dock import Dock
        from safe.test.utilities import load_standard_layers
        from qgis.PyQt.QtWidgets import QDockWidget
        from safe.gui.tools.extent_selector_dialog import ExtentSelectorDialog
        from safe.gui.tools.minimum_needs.needs_calculator_dialog import (
            NeedsCalculatorDialog
        )
        from safe.gui.tools.minimum_needs.needs_manager_dialog import (
            NeedsManagerDialog)
        from safe.gui.tools.options_dialog import OptionsDialog
            from safe.gui.widgets.message import getting_started_message
        from safe.gui.tools.options_dialog import OptionsDialog
        from safe.gui.tools.wizard.wizard_dialog import WizardDialog
        from safe.gui.tools.wizard.wizard_dialog import WizardDialog
        from safe.gui.tools.shake_grid.shakemap_converter_dialog import (
            ShakemapConverterDialog)
        from safe.gui.tools.multi_buffer_dialog import (
            MultiBufferDialog)
        from safe.gui.tools.osm_downloader_dialog import OsmDownloaderDialog
        from safe.gui.tools.geonode_uploader import GeonodeUploaderDialog
        from safe.utilities.help import show_help
        from safe.gui.tools.help import definitions_help
        from safe.gui.tools.field_mapping_dialog import FieldMappingDialog
        from safe.gui.tools.metadata_converter_dialog import (
            MetadataConverterDialog)
        from safe.gui.tools.multi_exposure_dialog import MultiExposureDialog
        from safe.gui.tools.peta_bencana_dialog import PetaBencanaDialog
        from safe.gui.tools.batch.batch_dialog import BatchDialog
        from safe.gui.tools.save_scenario import SaveScenarioDialog
            enable_keyword_wizard = False
        elif not hasattr(layer, 'providerType'):
            enable_keyword_wizard = False
        elif layer.providerType() == 'wms':
            enable_keyword_wizard = False
        else:
            enable_keyword_wizard = True

        try:
            if layer:
                if is_raster_layer(layer):
                    enable_field_mapping_tool = False
                else:
                    keywords = KeywordIO().read_keywords(layer)
                    keywords_version = keywords.get('keyword_version')
                    if not keywords_version:
                        supported = False
                    else:
                        supported = (
                            is_keyword_version_supported(keywords_version))
                    if not supported:
                        enable_field_mapping_tool = False
                    else:
                        layer_purpose = keywords.get('layer_purpose')

                        if not layer_purpose:
                            enable_field_mapping_tool = False
                        else:
                            if layer_purpose == layer_purpose_exposure['key']:
                                layer_subcategory = keywords.get('exposure')

# Path: safe/definitions/versions.py

# 
# Path: safe/definitions/layer_purposes.py



# Path: safe/plugin.py
import sys
import os
import qgis  # NOQA pylint: disable=unused-import
from functools import partial
from distutils.version import StrictVersion
from qgis.core import (
    QgsRectangle,
    QgsRasterLayer,
    QgsMapLayer,
    QgsExpression,
    QgsProject,
)
from qgis.PyQt.QtCore import QCoreApplication, Qt
from qgis.PyQt.QtWidgets import (
    QAction,
    QApplication,
    QToolButton,
    QMenu,
    QLineEdit,
    QInputDialog
)
from qgis.PyQt.QtGui import QIcon
from safe.common.custom_logging import LOGGER
from safe.utilities.expressions import qgis_expressions
from safe.definitions.versions import inasafe_release_status, inasafe_version
from safe.common.exceptions import (
    KeywordNotFoundError,
    NoKeywordsFoundError,
    MetadataReadError,
)
from safe.common.signals import send_static_message
from safe.utilities.resources import resources_path
from safe.utilities.gis import is_raster_layer
from safe.definitions.layer_purposes import (
    layer_purpose_exposure, layer_purpose_hazard
)
from safe.definitions.utilities import get_field_groups
from safe.utilities.i18n import tr
from safe.utilities.keyword_io import KeywordIO
from safe.utilities.utilities import is_keyword_version_supported
from safe.utilities.settings import setting, set_setting
        from safe.gui.widgets.dock import Dock
        from safe.test.utilities import load_standard_layers
        from qgis.PyQt.QtWidgets import QDockWidget
        from safe.gui.tools.extent_selector_dialog import ExtentSelectorDialog
        from safe.gui.tools.minimum_needs.needs_calculator_dialog import (
            NeedsCalculatorDialog
        )
        from safe.gui.tools.minimum_needs.needs_manager_dialog import (
            NeedsManagerDialog)
        from safe.gui.tools.options_dialog import OptionsDialog
            from safe.gui.widgets.message import getting_started_message
        from safe.gui.tools.options_dialog import OptionsDialog
        from safe.gui.tools.wizard.wizard_dialog import WizardDialog
        from safe.gui.tools.wizard.wizard_dialog import WizardDialog
        from safe.gui.tools.shake_grid.shakemap_converter_dialog import (
            ShakemapConverterDialog)
        from safe.gui.tools.multi_buffer_dialog import (
            MultiBufferDialog)
        from safe.gui.tools.osm_downloader_dialog import OsmDownloaderDialog
        from safe.gui.tools.geonode_uploader import GeonodeUploaderDialog
        from safe.utilities.help import show_help
        from safe.gui.tools.help import definitions_help
        from safe.gui.tools.field_mapping_dialog import FieldMappingDialog
        from safe.gui.tools.metadata_converter_dialog import (
            MetadataConverterDialog)
        from safe.gui.tools.multi_exposure_dialog import MultiExposureDialog
        from safe.gui.tools.peta_bencana_dialog import PetaBencanaDialog
        from safe.gui.tools.batch.batch_dialog import BatchDialog
        from safe.gui.tools.save_scenario import SaveScenarioDialog

            enable_keyword_wizard = False
        elif not hasattr(layer, 'providerType'):
            enable_keyword_wizard = False
        elif layer.providerType() == 'wms':
            enable_keyword_wizard = False
        else:
            enable_keyword_wizard = True

        try:
            if layer:
                if is_raster_layer(layer):
                    enable_field_mapping_tool = False
                else:
                    keywords = KeywordIO().read_keywords(layer)
                    keywords_version = keywords.get('keyword_version')
                    if not keywords_version:
                        supported = False
                    else:
                        supported = (
                            is_keyword_version_supported(keywords_version))
                    if not supported:
                        enable_field_mapping_tool = False
                    else:
                        layer_purpose = keywords.get('layer_purpose')

                        if not layer_purpose:
                            enable_field_mapping_tool = False
                        else:
                            if layer_purpose == layer_purpose_exposure['key']:
                                layer_subcategory = keywords.get('exposure')

                            elif layer_purpose == layer_purpose_hazard['key']: