From 06b670af47d8d49277f901cc20f459db166da609 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Sat, 30 Mar 2013 15:02:56 +0100 Subject: [PATCH] [cookboob] cap/app modified to handle interval number of persons --- weboob/applications/cookboob/cookboob.py | 5 ++++- weboob/capabilities/recipe.py | 10 ++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/weboob/applications/cookboob/cookboob.py b/weboob/applications/cookboob/cookboob.py index 0acafbd7..3f49c8a3 100644 --- a/weboob/applications/cookboob/cookboob.py +++ b/weboob/applications/cookboob/cookboob.py @@ -43,7 +43,10 @@ class RecipeInfoFormatter(IFormatter): if not empty(obj.cooking_time): result += 'Cooking time: %smin\n' % obj.cooking_time if not empty(obj.nb_person): - result += 'Amount of people: %s\n' % obj.nb_person + nbstr = obj.nb_person[0] + if len(obj.nb_person) > 1: + nbstr += '/%s' % obj.nb_person[1] + result += 'Amount of people: %s\n' % nbstr result += '\n%sIngredients%s\n' % (self.BOLD, self.NC) for i in obj.ingredients: result += ' * %s\n' % i diff --git a/weboob/capabilities/recipe.py b/weboob/capabilities/recipe.py index 261e06cd..3fa820fd 100644 --- a/weboob/capabilities/recipe.py +++ b/weboob/capabilities/recipe.py @@ -51,12 +51,12 @@ class Recipe(CapBaseObject): thumbnail_url = StringField('Direct url to recipe thumbnail') picture_url = StringField('Direct url to recipe picture') short_description = StringField('Short description of a recipe') - nb_person = IntField('The recipe was made for this amount of persons') + nb_person = Field('The recipe was made for this amount of persons', list) preparation_time = IntField('Preparation time of the recipe in minutes') cooking_time = IntField('Cooking time of the recipe in minutes') - ingredients = Field('Ingredient list necessary for the recipe',list) + ingredients = Field('Ingredient list necessary for the recipe', list) instructions = StringField('Instruction step list of the recipe') - comments = Field('User comments about the recipe',list) + comments = Field('User comments about the recipe', list) def __init__(self, id, title): CapBaseObject.__init__(self, id) @@ -91,7 +91,9 @@ class Recipe(CapBaseObject): eyield = ET.SubElement(desc, 'yield') if not empty(self.nb_person): amount = ET.SubElement(eyield, 'amount') - amount.text = '%s' % self.nb_person + amount.text = '%s' % self.nb_person[0] + if len(self.nb_person) > 1: + amount.text += '/%s' % self.nb_person[1] etype = ET.SubElement(eyield, 'type') etype.text = 'persons' if not empty(self.preparation_time):