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


Python Unit.serialize方法代码示例

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


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

示例1: ResourceParameter

# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import serialize [as 别名]
class ResourceParameter(FloatParameter):
    """A parameter handling specifically the resources used in InaSAFE
    minimum needs.

    :param guid: The unique reference to use when addressing this value.
    :type guid: str, None
    """
    def __init__(self, guid=None):
        super(ResourceParameter, self).__init__(guid)
        self._frequency = ''
        self._unit = Unit()

    @property
    def frequency(self):
        """The frequency that the resource needs to be supplied getter.

        :returns: The frequency.
        :rtype: str
        """
        return self._frequency

    @frequency.setter
    def frequency(self, frequency):
        """Set the frequency that the resource needs to be supplied.

        :param frequency: The frequency of the resource.
        :type frequency: str

        """
        self._frequency = frequency

    def serialize(self):
        """Convert the parameter into a dictionary.

        :return: The parameter dictionary.
        :rtype: dict
        """
        pickle = super(ResourceParameter, self).serialize()
        pickle['frequency'] = self.frequency
        pickle['unit'] = self._unit.serialize()
        return pickle

    @property
    def unit(self):
        """Property for the unit for the parameter.

        :returns: The unit of the parameter.
        :rtype: Unit

        """
        return self._unit

    @unit.setter
    def unit(self, unit):
        """Setter for unit for the parameter.

        :param unit: Unit for parameter
        :type unit: Unit

        """
        self._unit.name = unit
开发者ID:cccs-ip,项目名称:inasafe,代码行数:63,代码来源:resource_parameter.py


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