本文整理匯總了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