當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。