Пример #1
0
    def hops(self):
        """Return markdown to represent the recipe's hops."""
        headers = ('Name', 'Origin', 'Alpha', 'Amount', 'Time', 'Use')
        rows = []
        for hop in self.recipe.hops:
            # Determine hop unit
            if self.hop_unit == 'pounds':
                amt = convert.pounds(hop.amount, '.2f')
            elif self.hop_unit == 'grams':
                amt = convert.grams(hop.amount, '.1f')
            elif self.hop_unit == 'kilograms':
                amt = convert.kilograms(hop.amount, '.2f')
            else:
                amt = convert.ounces(hop.amount, '.1f')

            # Determine hop timing
            if hop.use == 'Dry Hop':
                # 1 day = 1440 minutes
                time = '{:.1f} days'.format(hop.time / 1440.0)
            else:
                time = '{} min'.format(int(round(hop.time)))
            rows.append((
                hop.name,
                hop.origin,
                '{:.1f} %'.format(hop.alpha),
                amt,
                time,
                hop.use,
            ))
        return ('{}\n{}'.format(markdown.setext_heading('Hops', level=2),
                                markdown.table(headers, rows)))
Пример #2
0
    def details(self):
        """Return markdown for the recipe's details."""
        if self.vol_unit == 'gallons':
            boil_size = convert.gallons(self.recipe.boil_size, '.1f')
            batch_size = convert.gallons(self.recipe.batch_size, '.1f')
        else:
            boil_size = convert.liters(self.recipe.boil_size, '.1f')
            batch_size = convert.liters(self.recipe.batch_size, '.1f')

        heading = markdown.setext_heading('Details', 2) + '\n'

        return heading + '\\\n'.join(
            ('{}: {}'.format(markdown.strong('Type'), self.recipe.type),
             '{}: {:.1f} %'.format(markdown.strong('Batch efficiency'),
                                   self.recipe.efficiency),
             '{}: {}'.format(markdown.strong('Boil size'), boil_size),
             '{}: {} min'.format(markdown.strong('Boil length'),
                                 int(self.recipe.boil_time)),
             '{}: {}'.format(markdown.strong('Batch size'), batch_size),
             '{}: {:.3f}'.format(markdown.strong('Estimated OG'),
                                 self.recipe.og), '{}: {:.3f}'.format(
                                     markdown.strong('Estimated FG'),
                                     self.recipe.fg),
             '{}: {}'.format(markdown.strong('Estimated IBU'),
                             int(self.recipe.ibu)), '{}: {:.1f}'.format(
                                 markdown.strong('Estimated SRM'),
                                 self.recipe.color), '{}: {:.1f} %'.format(
                                     markdown.strong('Estimated ABV'),
                                     self.recipe.abv)))
Пример #3
0
 def style(self):
     """Return markdown for the recipe's style."""
     heading = markdown.setext_heading('Style', 2) + '\n'
     return heading + '\\\n'.join(('{}: {}'.format(
         markdown.strong('Style guide'),
         self.recipe.style.style_guide), '{}: {}{}'.format(
             markdown.strong('Style category'),
             int(self.recipe.style.category_number),
             self.recipe.style.style_letter), '{}: {}'.format(
                 markdown.strong('Style name'), self.recipe.style.name)))
Пример #4
0
 def yeast(self):
     """Return markdown to represent the recipe's yeast."""
     headers = ('Name', 'Lab', 'Type', 'Attenuation')
     rows = []
     for yeast in self.recipe.yeasts:
         rows.append((
             yeast.name,
             yeast.laboratory,
             yeast.type,
             '{:.1f} %'.format(yeast.attenuation),
         ))
     return ('{}\n{}'.format(markdown.setext_heading('Yeast', level=2),
                             markdown.table(headers, rows)))
Пример #5
0
    def miscs(self):
        """Return the markdown to represent the recipe's other ingredients."""
        if len(self.recipe.miscs) == 0:
            return ''

        headers = ('Name', 'Use', 'Amount')
        rows = []
        for misc in self.recipe.miscs:
            if misc.display_amount is not None:
                amt = str(misc.display_amount)
            elif misc.amount_is_weight:
                amt = '{:.2f} kg'.format(misc.amount)
            else:
                amt = '{:.2f} L'.format(misc.amount)
            rows.append((misc.name, misc.use, amt))
        return ('{}\n{}'.format(
            markdown.setext_heading('Other Ingredients', level=2),
            markdown.table(headers, rows)))
Пример #6
0
 def fermentables(self):
     """Return markdown to represent the recipe's fermentables."""
     headers = ('Name', 'Type', 'Color', 'Amount')
     rows = []
     for fermentable in self.recipe.fermentables:
         if self.fermentable_unit == 'ounces':
             amt = convert.ounces(fermentable.amount, '.1f')
         elif self.fermentable_unit == 'grams':
             amt = convert.grams(fermentable.amount, '.1f')
         elif self.fermentable_unit == 'kilograms':
             amt = convert.kilograms(fermentable.amount, '.2f')
         else:
             amt = convert.pounds(fermentable.amount, '.2f')
         rows.append((fermentable.name, fermentable.type,
                      '{:.1f} °L'.format(fermentable.color), amt))
     return ('{}\n{}'.format(
         markdown.setext_heading('Fermentables', level=2),
         markdown.table(headers, rows)))
Пример #7
0
    def mash(self):
        """Return the markdown to represent the recipe's mash steps."""
        if self.recipe.mash is None:
            return ''

        headers = ('Name', 'Type', 'Temperature', 'Time', 'Amount')
        rows = []
        for step in self.recipe.mash.steps:
            if self.temp_unit == 'celsius':
                temp = convert.celsius(step.step_temp, '.1f')
            else:
                temp = convert.fahrenheit(step.step_temp, '.1f')
            if self.vol_unit == 'gallons':
                amt = convert.gallons(step.infuse_amount, '.1f')
            else:
                amt = convert.liters(step.infuse_amount, '.1f')
            rows.append((step.name, step.type, temp,
                         '{} min'.format(int(step.step_time)), amt))
        return ('{}\n{}'.format(markdown.setext_heading('Mash', level=2),
                                markdown.table(headers, rows)))
Пример #8
0
def test_setext_heading(text, level, expected):
    """Test for valid setext headings from setext_heading function."""
    assert markdown.setext_heading(text, level) == expected
Пример #9
0
 def name(self):
     """Return markdown for the recipe's name."""
     return markdown.setext_heading(self.recipe.name, 1)