本文整理汇总了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