当前位置: 首页>>代码示例>>Python>>正文


Python ResourceParameter.help_text方法代码示例

本文整理汇总了Python中safe.common.resource_parameter.ResourceParameter.help_text方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceParameter.help_text方法的具体用法?Python ResourceParameter.help_text怎么用?Python ResourceParameter.help_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在safe.common.resource_parameter.ResourceParameter的用法示例。


在下文中一共展示了ResourceParameter.help_text方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_needs_parameters

# 需要导入模块: from safe.common.resource_parameter import ResourceParameter [as 别名]
# 或者: from safe.common.resource_parameter.ResourceParameter import help_text [as 别名]
    def get_needs_parameters(self):
        """Get the minimum needs resources in parameter format

        :returns: The minimum needs resources wrapped in parameters.
        :rtype: list
        """
        parameters = []
        for resource in self.minimum_needs['resources']:
            parameter = ResourceParameter()
            parameter.name = resource['Resource name']
            parameter.help_text = resource['Resource description']
            # Adding in the frequency property. This is not in the
            # FloatParameter by default, so maybe we should subclass.
            parameter.frequency = resource['Frequency']
            parameter.description = self.format_sentence(
                resource['Readable sentence'],
                resource)
            parameter.minimum_allowed_value = float(
                resource['Minimum allowed'])
            parameter.maximum_allowed_value = float(
                resource['Maximum allowed'])
            parameter.unit.name = resource['Unit']
            parameter.unit.plural = resource['Units']
            parameter.unit.abbreviation = resource['Unit abbreviation']
            parameter.value = float(resource['Default'])
            parameters.append(parameter)
        return parameters
开发者ID:severinmenard,项目名称:inasafe,代码行数:29,代码来源:needs_profile.py

示例2: default_minimum_needs

# 需要导入模块: from safe.common.resource_parameter import ResourceParameter [as 别名]
# 或者: from safe.common.resource_parameter.ResourceParameter import help_text [as 别名]
def default_minimum_needs():
    """Helper to get the default minimum needs.

    .. note:: Key names will be translated.
    """
    # TODO: update this to use parameters
    rice = ResourceParameter()
    rice.value = 2.8
    rice.frequency = tr("weekly")
    rice.minimum_allowed_value = 1.4
    rice.maximum_allowed_value = 5.6
    rice.name = tr("Rice")
    rice.unit.abbreviation = tr("kg")
    rice.unit.name = tr("kilogram")
    rice.unit.plural = tr("kilograms")

    drinking_water = ResourceParameter()
    drinking_water.value = 17.5
    drinking_water.frequency = tr("weekly")
    drinking_water.minimum_allowed_value = 10
    drinking_water.maximum_allowed_value = 30
    drinking_water.name = tr("Drinking Water")
    drinking_water.unit.abbreviation = tr("l")
    drinking_water.unit.name = tr("litre")
    drinking_water.unit.plural = tr("litres")

    water = ResourceParameter()
    water.value = 67
    water.frequency = tr("weekly")
    water.minimum_allowed_value = 30
    water.maximum_allowed_value = 100
    water.name = tr("Clean Water")
    water.unit.abbreviation = tr("l")
    water.unit.name = tr("litre")
    water.unit.plural = tr("litres")

    family_kits = ResourceParameter()
    family_kits.value = 0.2
    family_kits.frequency = tr("weekly")
    family_kits.minimum_allowed_value = 0.2
    family_kits.maximum_allowed_value = 0.2
    family_kits.name = tr("Family Kits")

    toilets = ResourceParameter()
    toilets.value = 0.05
    toilets.frequency = tr("single")
    toilets.minimum_allowed_value = 0.02
    toilets.maximum_allowed_value = 0.05
    toilets.name = tr("Toilets")
    toilets.help_text = tr(
        "Toilets are not provided on a regular basis - it is expected that "
        "installed toilets will continue to be usable."
    )

    provenance = default_provenance()

    minimum_needs = [rice, drinking_water, water, family_kits, toilets, provenance]
    return minimum_needs
开发者ID:inasafe,项目名称:inasafe,代码行数:60,代码来源:defaults.py

示例3: test_init

# 需要导入模块: from safe.common.resource_parameter import ResourceParameter [as 别名]
# 或者: from safe.common.resource_parameter.ResourceParameter import help_text [as 别名]
    def test_init(self):
        unit_feet = Unit("130790")
        unit_feet.load_dictionary(unit_feet_depth)

        unit_metres = Unit("900713")
        unit_metres.load_dictionary(unit_metres_depth)

        resource_parameter = ResourceParameter()
        resource_parameter.name = "Flood Depth"
        resource_parameter.is_required = True
        resource_parameter.precision = 3
        resource_parameter.minimum_allowed_value = 1.0
        resource_parameter.maximum_allowed_value = 2.0
        resource_parameter.help_text = "The depth of flood."
        resource_parameter.description = (
            "A <b>test _description</b> that is very long so that you need "
            "to read it for one minute and you will be tired after read this "
            "description. You are the best user so far. Even better if you "
            "read this description loudly so that all of your friends will be "
            "able to hear you"
        )
        resource_parameter.unit = unit_feet
        resource_parameter.allowed_units = [unit_metres, unit_feet]
        resource_parameter.value = 1.12

        widget = ResourceParameterWidget(resource_parameter)

        expected_value = resource_parameter.name
        real_value = widget._label.text()
        message = "Expected %s get %s" % (expected_value, real_value)
        self.assertEqual(expected_value, real_value, message)

        expected_value = resource_parameter.value
        real_value = widget.get_parameter().value
        message = "Expected %s get %s" % (expected_value, real_value)
        self.assertEqual(expected_value, real_value, message)

        widget.set_value(1.5)

        expected_value = 1.5
        real_value = widget.get_parameter().value
        message = "Expected %s get %s" % (expected_value, real_value)
        self.assertEqual(expected_value, real_value, message)

        widget.set_value(1.55555)

        expected_value = 1.556
        real_value = widget.get_parameter().value
        message = "Expected %s get %s" % (expected_value, real_value)
        self.assertEqual(expected_value, real_value, message)

        widget.set_value(7)

        expected_value = 2
        real_value = widget.get_parameter().value
        message = "Expected %s get %s" % (expected_value, real_value)
        self.assertEqual(expected_value, real_value, message)
开发者ID:tomkralidis,项目名称:inasafe,代码行数:59,代码来源:test_resource_parameter_widget.py

示例4: get_needs_parameters

# 需要导入模块: from safe.common.resource_parameter import ResourceParameter [as 别名]
# 或者: from safe.common.resource_parameter.ResourceParameter import help_text [as 别名]
    def get_needs_parameters(self):
        """Get the minimum needs resources in parameter format

        :returns: The minimum needs resources wrapped in parameters.
        :rtype: list
        """
        parameters = []
        for resource in self.minimum_needs['resources']:
            parameter = ResourceParameter()
            parameter.name = resource['Resource name']
            parameter.help_text = resource['Resource description']
            # Adding in the frequency property. This is not in the
            # FloatParameter by default, so maybe we should subclass.
            parameter.frequency = resource['Frequency']
            parameter.description = self.format_sentence(
                resource['Readable sentence'],
                resource)
            parameter.minimum_allowed_value = float(
                resource['Minimum allowed'])
            parameter.maximum_allowed_value = float(
                resource['Maximum allowed'])
            parameter.unit.name = resource['Unit']
            parameter.unit.plural = resource['Units']
            parameter.unit.abbreviation = resource['Unit abbreviation']
            parameter.value = float(resource['Default'])
            # choose highest precision between resource's parameters
            # start with default of 1
            precisions = [1]
            precision_influence = [
                'Maximum allowed', 'Minimum allowed', 'Default']
            for element in precision_influence:
                resource_element = str(resource[element])
                if resource[element] is not None and '.' in resource_element:
                    precisions.append(self.precision_of(resource_element))

            parameter.precision = max(precisions)
            parameters.append(parameter)

        prov_parameter = TextParameter()
        prov_parameter.name = tr('Provenance')
        prov_parameter.description = tr('The provenance of minimum needs')
        prov_parameter.help_text = tr('The provenance of minimum needs')
        try:
            prov_parameter.value = self.provenance
        except TypeError:
            prov_parameter.value = ''
        parameters.append(prov_parameter)

        return parameters
开发者ID:easmetz,项目名称:inasafe,代码行数:51,代码来源:needs_profile.py

示例5: save_resource

# 需要导入模块: from safe.common.resource_parameter import ResourceParameter [as 别名]
# 或者: from safe.common.resource_parameter.ResourceParameter import help_text [as 别名]
    def save_resource(self):
        """Accept the add/edit of the current resource.
        """
        # --
        # Hackorama to get this working outside the method that the
        # parameters where defined in.
        parameters_widget = [
            self.parameters_scrollarea.layout().itemAt(i) for i in
            range(self.parameters_scrollarea.layout().count())][0]
        parameters = parameters_widget.widget().get_parameters()

        # To store parameters, we need the english version.
        translated_to_english = dict(
            (y, x) for x, y in self.resource_parameters.iteritems())
        resource = {}
        for parameter in parameters:
            resource[translated_to_english[parameter.name]] = parameter.value

        # verify the parameters are ok - create a throw-away resource param
        try:
            parameter = ResourceParameter()
            parameter.name = resource['Resource name']
            parameter.help_text = resource['Resource description']
            # Adding in the frequency property. This is not in the
            # FloatParameter by default, so maybe we should subclass.
            parameter.frequency = resource['Frequency']
            parameter.description = NeedsProfile.format_sentence(
                resource['Readable sentence'],
                resource)
            parameter.minimum_allowed_value = float(
                resource['Minimum allowed'])
            parameter.maximum_allowed_value = float(
                resource['Maximum allowed'])
            parameter.unit.name = resource['Unit']
            parameter.unit.plural = resource['Units']
            parameter.unit.abbreviation = resource['Unit abbreviation']
            parameter.value = float(resource['Default'])
        except ValueOutOfBounds, e:
            warning = self.tr(
                'Problem - default value is invalid') + '\n' + e.message
            # noinspection PyTypeChecker,PyArgumentList
            QMessageBox.warning(None, 'InaSAFE', warning)
            return
开发者ID:jobel-openscience,项目名称:inasafe,代码行数:45,代码来源:needs_manager_dialog.py

示例6: default_minimum_needs

# 需要导入模块: from safe.common.resource_parameter import ResourceParameter [as 别名]
# 或者: from safe.common.resource_parameter.ResourceParameter import help_text [as 别名]
def default_minimum_needs():
    """Helper to get the default minimum needs.

    .. note:: Key names will be translated.
    """
    # TODO: update this to use parameters
    rice = ResourceParameter()
    rice.value = 2.8
    rice.frequency = tr('weekly')
    rice.minimum_allowed_value = 1.4
    rice.maximum_allowed_value = 5.6
    rice.name = tr('Rice')
    rice.unit.abbreviation = tr('kg')
    rice.unit.name = tr('kilogram')
    rice.unit.plural = tr('kilograms')

    drinking_water = ResourceParameter()
    drinking_water.value = 17.5
    drinking_water.frequency = tr('weekly')
    drinking_water.minimum_allowed_value = 10
    drinking_water.maximum_allowed_value = 30
    drinking_water.name = tr('Drinking Water')
    drinking_water.unit.abbreviation = tr('l')
    drinking_water.unit.name = tr('litre')
    drinking_water.unit.plural = tr('litres')

    water = ResourceParameter()
    water.value = 67
    water.frequency = tr('weekly')
    water.minimum_allowed_value = 30
    water.maximum_allowed_value = 100
    water.name = tr('Clean Water')
    water.unit.abbreviation = tr('l')
    water.unit.name = tr('litre')
    water.unit.plural = tr('litres')

    family_kits = ResourceParameter()
    family_kits.value = 0.2
    family_kits.frequency = tr('weekly')
    family_kits.minimum_allowed_value = 0.2
    family_kits.maximum_allowed_value = 0.2
    family_kits.name = tr('Family Kits')

    toilets = ResourceParameter()
    toilets.value = 0.05
    toilets.frequency = tr('single')
    toilets.minimum_allowed_value = 0.02
    toilets.maximum_allowed_value = 0.05
    toilets.name = tr('Toilets')
    toilets.help_text = tr(
        'Toilets are not provided on a regular bases - it is expected that '
        'installed toilets will be usable on a continuous basis.'
    )

    minimum_needs = [
        rice,
        drinking_water,
        water,
        family_kits,
        toilets,
    ]
    return minimum_needs
开发者ID:Charlotte-Morgan,项目名称:inasafe,代码行数:64,代码来源:defaults.py


注:本文中的safe.common.resource_parameter.ResourceParameter.help_text方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。