From ccea968b12835a39920b63fb30724cdca776eb8d Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Fri, 15 Mar 2013 11:45:09 +0100 Subject: [PATCH] [cookboob] less mandatory fields in formatter, minutes display --- modules/marmiton/pages.py | 1 + weboob/applications/cookboob/cookboob.py | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/marmiton/pages.py b/modules/marmiton/pages.py index 4ec631b4ba..95c2b4eb73 100644 --- a/modules/marmiton/pages.py +++ b/modules/marmiton/pages.py @@ -82,6 +82,7 @@ def get_recipe(self, id): instructions = u'' for line in rinstructions.split('\n'): instructions += '%s\n'%line.strip() + instructions = instructions.strip('\n') imgillu = self.parser.select(self.document.getroot(),'a.m_content_recette_illu img') if len(imgillu) > 0: picture_url = unicode(imgillu[0].attrib.get('src','')) diff --git a/weboob/applications/cookboob/cookboob.py b/weboob/applications/cookboob/cookboob.py index 5209e1bf37..db5a3e9884 100644 --- a/weboob/applications/cookboob/cookboob.py +++ b/weboob/applications/cookboob/cookboob.py @@ -31,22 +31,25 @@ class RecipeInfoFormatter(IFormatter): - MANDATORY_FIELDS = ('id', 'title', 'preparation_time', 'cooking_time', 'ingredients', 'instructions', 'nb_person', 'comments') + MANDATORY_FIELDS = ('id', 'title', 'preparation_time', 'ingredients', 'instructions') def format_obj(self, obj, alias): result = u'%s%s%s\n' % (self.BOLD, obj.title, self.NC) result += 'ID: %s\n' % obj.fullid - result += 'Preparation time: %s\n' % obj.preparation_time - result += 'Cooking time: %s\n' % obj.cooking_time - result += 'Amount of people: %s\n' % obj.nb_person + result += 'Preparation time: %smin\n' % obj.preparation_time + if obj.cooking_time != NotAvailable: + result += 'Cooking time: %smin\n' % obj.cooking_time + if obj.nb_person != NotAvailable: + result += 'Amount of people: %s\n' % obj.nb_person result += '\n%sIngredients%s\n' % (self.BOLD, self.NC) for i in obj.ingredients: result += ' * %s\n'%i result += '\n%sInstructions%s\n' % (self.BOLD, self.NC) result += '%s\n'%obj.instructions - result += '\n%sComments%s\n' % (self.BOLD, self.NC) - for c in obj.comments: - result += ' * %s\n'%c + if obj.comments != NotAvailable: + result += '\n%sComments%s\n' % (self.BOLD, self.NC) + for c in obj.comments: + result += ' * %s\n'%c return result -- GitLab