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


Python Timer.isoformat方法代码示例

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


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

示例1: deserialize

# 需要导入模块: from utils import Timer [as 别名]
# 或者: from utils.Timer import isoformat [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
开发者ID:g-div,项目名称:semanticfood,代码行数:43,代码来源:recipe.py


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