本文整理汇总了Python中utils.Timer.getString方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.getString方法的具体用法?Python Timer.getString怎么用?Python Timer.getString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.Timer
的用法示例。
在下文中一共展示了Timer.getString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deserialize
# 需要导入模块: from utils import Timer [as 别名]
# 或者: from utils.Timer import getString [as 别名]
def deserialize(self, resource):
"""Convert triples to recipe object"""
self.name = resource.value(RDFS.label)
self.description = resource.value(RDFS.comment)
timer = Timer(resource.value(SFO.prepTime))
self.prepTime = timer.getString()
self.prepTime_iso = timer.isoformat()
timer = Timer(resource.value(SFO.cookTime))
self.cookTime = timer.getString()
self.cookTime_iso = timer.isoformat()
self.servings = resource.value(FO.serves)
self.fat = resource.value(NUTRIENT.fatPer100g) or 0
self.saturatedFat = resource.value(NUTRIENT.saturatedFatPer100g) or 0
self.unsaturatedFat = round(float(resource.value(NUTRIENT.monounsaturatedFatPer100g) or 0) + float(resource.value(NUTRIENT.polyunsaturatedFatPer100g) or 0), 2)
self.monounsaturatedFat = resource.value(NUTRIENT.monounsaturatedFatPer100g) or 0
self.polyunsaturatedFat = resource.value(NUTRIENT.polyunsaturatedFatPer100g) or 0
self.transFat = resource.value(NUTRIENT.transFatPer100g) or 0
self.calories = resource.value(NUTRIENT.energyPer100g) or 0
self.proteins = resource.value(NUTRIENT.proteinsPer100g) or 0
self.carbohydrates = resource.value(NUTRIENT.carbohydratesPer100g) or 0
self.cholesterol = resource.value(NUTRIENT.cholesterolPer100g) or 0
self.sodium = resource.value(NUTRIENT.sodiumPer100g) or 0
self.fibers = resource.value(NUTRIENT.fiberPer100g) or 0
self.sugars = resource.value(NUTRIENT.sugarsPer100g) or 0
# TODO: add instructions
self.ingredients = []
ingredientList = resource.value(SFO.ingredients)
for ingredient in ingredientList.objects(FO.ingredients):
name = ingredient.value(FO.food).value(RDFS.label)
quantity = ingredient.value(FO.metric_quantity)
self.ingredients.append('{} {}'.format(quantity, name))
self.steps = []
stepList = resource.value(SFO.steps)
for step in stepList.objects(SFO.steps):
self.steps.append(step.value(FO.instruction))
return self