def classifications_for_layer(self): """Return a list of valid classifications for a layer. :returns: A list where each value represents a valid classification. :rtype: list """ subcategory_key = self.parent.step_kw_subcategory.\ selected_subcategory()['key'] layer_purpose = self.parent.step_kw_purpose.selected_purpose() if layer_purpose in [layer_purpose_hazard, layer_purpose_exposure]: classifications = [] selected_unit = self.parent.step_kw_unit.selected_unit() for classification in get_classifications(subcategory_key): if selected_unit is None: # we are using classified data, so let's allow all # classifications classifications.append(classification) elif 'multiple_units' not in classification: # this classification is not multiple unit aware, so let's # allow it classifications.append(classification) elif selected_unit in classification['multiple_units']: # we are using continuous data, and this classification # supports the chosen unit so we allow it classifications.append(classification) return classifications else: # There are no classifications for non exposure and hazard # defined yet return []
def classifications_for_layer(self): """Return a list of valid classifications for a layer. :returns: A list where each value represents a valid classification. :rtype: list """ subcategory_key = self.parent.step_kw_subcategory.\ selected_subcategory()['key'] layer_purpose = self.parent.step_kw_purpose.selected_purpose() if layer_purpose in [layer_purpose_hazard, layer_purpose_exposure]: classifications = [] selected_unit = self.parent.step_kw_unit.selected_unit() for classification in get_classifications(subcategory_key): if selected_unit is None: # we are using classified data, so let's allow all # classifications classifications.append(classification) elif 'multiple_units' not in classification: # this classification is not multiple unit aware, so let's # allow it classifications.append(classification) elif selected_unit in classification['multiple_units']: # we are using continuous data, and this classification # supports the chosen unit so we allow it classifications.append(classification) return classifications else: # There are no classifications for non exposure and hazard # defined yet return []
def test_hazards_classifications(self): """Test for get_hazards_classifications.""" self.maxDiff = None expected = [ flood_hazard_classes, flood_petabencana_hazard_classes, generic_hazard_classes ] self.assertItemsEqual(get_classifications('flood'), expected)
def test_hazards_classifications(self): """Test for get_hazards_classifications.""" self.maxDiff = None expected = [ flood_hazard_classes, flood_petabencana_hazard_classes, generic_hazard_classes] self.assertEqual( get_classifications('flood'), expected)
def get_next_step(self): """Find the proper step when user clicks the Next button. :returns: The step to be switched to. :rtype: WizardStep instance or None """ subcategory = self.parent.step_kw_subcategory.selected_subcategory() is_raster = is_raster_layer(self.parent.layer) has_classifications = get_classifications(subcategory['key']) # Vector if not is_raster: return self.parent.step_kw_field # Raster and has classifications elif has_classifications: return self.parent.step_kw_multi_classifications # else go to source return self.parent.step_kw_source
def get_next_step(self): """Find the proper step when user clicks the Next button. :returns: The step to be switched to. :rtype: WizardStep instance or None """ subcategory = self.parent.step_kw_subcategory.selected_subcategory() is_raster = is_raster_layer(self.parent.layer) has_classifications = get_classifications(subcategory['key']) # Vector if not is_raster: return self.parent.step_kw_field # Raster and has classifications elif has_classifications: return self.parent.step_kw_multi_classifications # else go to source return self.parent.step_kw_source