[cookboob] less mandatory fields in formatter, minutes display
This commit is contained in:
parent
4798fdd411
commit
ccea968b12
2 changed files with 11 additions and 7 deletions
|
|
@ -82,6 +82,7 @@ class RecipePage(BasePage):
|
||||||
instructions = u''
|
instructions = u''
|
||||||
for line in rinstructions.split('\n'):
|
for line in rinstructions.split('\n'):
|
||||||
instructions += '%s\n'%line.strip()
|
instructions += '%s\n'%line.strip()
|
||||||
|
instructions = instructions.strip('\n')
|
||||||
imgillu = self.parser.select(self.document.getroot(),'a.m_content_recette_illu img')
|
imgillu = self.parser.select(self.document.getroot(),'a.m_content_recette_illu img')
|
||||||
if len(imgillu) > 0:
|
if len(imgillu) > 0:
|
||||||
picture_url = unicode(imgillu[0].attrib.get('src',''))
|
picture_url = unicode(imgillu[0].attrib.get('src',''))
|
||||||
|
|
|
||||||
|
|
@ -31,22 +31,25 @@ __all__ = ['Cookboob']
|
||||||
|
|
||||||
|
|
||||||
class RecipeInfoFormatter(IFormatter):
|
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):
|
def format_obj(self, obj, alias):
|
||||||
result = u'%s%s%s\n' % (self.BOLD, obj.title, self.NC)
|
result = u'%s%s%s\n' % (self.BOLD, obj.title, self.NC)
|
||||||
result += 'ID: %s\n' % obj.fullid
|
result += 'ID: %s\n' % obj.fullid
|
||||||
result += 'Preparation time: %s\n' % obj.preparation_time
|
result += 'Preparation time: %smin\n' % obj.preparation_time
|
||||||
result += 'Cooking time: %s\n' % obj.cooking_time
|
if obj.cooking_time != NotAvailable:
|
||||||
result += 'Amount of people: %s\n' % obj.nb_person
|
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)
|
result += '\n%sIngredients%s\n' % (self.BOLD, self.NC)
|
||||||
for i in obj.ingredients:
|
for i in obj.ingredients:
|
||||||
result += ' * %s\n'%i
|
result += ' * %s\n'%i
|
||||||
result += '\n%sInstructions%s\n' % (self.BOLD, self.NC)
|
result += '\n%sInstructions%s\n' % (self.BOLD, self.NC)
|
||||||
result += '%s\n'%obj.instructions
|
result += '%s\n'%obj.instructions
|
||||||
result += '\n%sComments%s\n' % (self.BOLD, self.NC)
|
if obj.comments != NotAvailable:
|
||||||
for c in obj.comments:
|
result += '\n%sComments%s\n' % (self.BOLD, self.NC)
|
||||||
result += ' * %s\n'%c
|
for c in obj.comments:
|
||||||
|
result += ' * %s\n'%c
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue