Commit ccea968b authored by Julien Veyssier's avatar Julien Veyssier

[cookboob] less mandatory fields in formatter, minutes display

parent 4798fdd4
......@@ -82,6 +82,7 @@ class RecipePage(BasePage):
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',''))
......
......@@ -31,22 +31,25 @@ __all__ = ['Cookboob']
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment