Source code for safe.impact_functions.unit_definitions

# coding=utf-8
from safe.definitions import unit_generic, unit_metres, unit_mmi, \
    unit_percentage
from safe_extras.parameters.unit import Unit

__author__ = 'Rizky Maulana Nugraha "lucernae" <[email protected]>'
__date__ = '11/06/15'


[docs]def convert_to_parameter_unit(unit_definition): unit = Unit() unit.name = unit_definition.get('name') unit.plural = unit_definition.get('plural_name') unit.abbreviation = unit_definition.get('abbreviation') unit.description = unit_definition.get('description') return unit
[docs]def parameter_unit_generic(): return convert_to_parameter_unit(unit_generic)
[docs]def parameter_unit_metres(): return convert_to_parameter_unit(unit_metres)
[docs]def parameter_unit_mmi(): return convert_to_parameter_unit(unit_mmi)
[docs]def parameter_unit_percentage(): return convert_to_parameter_unit(unit_percentage)