mirror of
https://github.com/shouptech/synthale.git
synced 2026-02-03 15:39:45 +00:00
Add mash steps
This commit is contained in:
parent
56c0439968
commit
39318f8ed1
2 changed files with 50 additions and 2 deletions
|
|
@ -16,13 +16,15 @@ class MarkdownRecipe:
|
||||||
recipe,
|
recipe,
|
||||||
vol_unit='gallons',
|
vol_unit='gallons',
|
||||||
hop_unit='ounces',
|
hop_unit='ounces',
|
||||||
fermentable_unit='pounds'):
|
fermentable_unit='pounds',
|
||||||
|
temp_unit='fahrenheit'):
|
||||||
"""Create a MarkdownRecipe object.
|
"""Create a MarkdownRecipe object.
|
||||||
|
|
||||||
`recipe` is a recipe object from the pybeerxml package.
|
`recipe` is a recipe object from the pybeerxml package.
|
||||||
|
|
||||||
`vol_unit` specifies the unit for boil size and batch size. Can be one
|
`vol_unit` specifies the unit for boil size and batch size. Can be one
|
||||||
of 'gallons', or 'liters'.
|
of 'gallons', or 'liters'. If specified unit is not matched, default is
|
||||||
|
'liters'.
|
||||||
|
|
||||||
`hop_unit` specifies the unit for hop amounts. Can be one of
|
`hop_unit` specifies the unit for hop amounts. Can be one of
|
||||||
'ounces', 'pounds', 'grams', or 'kilograms'. If specified unit is not
|
'ounces', 'pounds', 'grams', or 'kilograms'. If specified unit is not
|
||||||
|
|
@ -31,11 +33,16 @@ class MarkdownRecipe:
|
||||||
`fermentable_unit` specifies the unit for fermentable amounts. Can be
|
`fermentable_unit` specifies the unit for fermentable amounts. Can be
|
||||||
one of 'ounces', 'pounds', 'grams', or 'kilograms'. If specified unit
|
one of 'ounces', 'pounds', 'grams', or 'kilograms'. If specified unit
|
||||||
is not matched, default is 'pounds'.
|
is not matched, default is 'pounds'.
|
||||||
|
|
||||||
|
`temp_unit` specifies the unit for temperatures. Can be one of
|
||||||
|
'fahrenheit' or 'celsius'. If specified unit is not matched, default is
|
||||||
|
'fahrenheit'.
|
||||||
"""
|
"""
|
||||||
self.recipe = recipe
|
self.recipe = recipe
|
||||||
self.vol_unit = vol_unit
|
self.vol_unit = vol_unit
|
||||||
self.hop_unit = hop_unit
|
self.hop_unit = hop_unit
|
||||||
self.fermentable_unit = fermentable_unit
|
self.fermentable_unit = fermentable_unit
|
||||||
|
self.temp_unit = temp_unit
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def filename(self):
|
def filename(self):
|
||||||
|
|
@ -71,6 +78,8 @@ class MarkdownRecipe:
|
||||||
'',
|
'',
|
||||||
self.miscs,
|
self.miscs,
|
||||||
'',
|
'',
|
||||||
|
self.mash,
|
||||||
|
'',
|
||||||
))
|
))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
@ -223,6 +232,34 @@ class MarkdownRecipe:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def mash(self):
|
||||||
|
"""Return the markdown to represent the recipe's mash steps."""
|
||||||
|
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)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def load_file(path):
|
def load_file(path):
|
||||||
"""Parse BeerXML file located at `path`.
|
"""Parse BeerXML file located at `path`.
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,17 @@ def test_recipe_miscs(md_coffee_stout):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_recipe_mash(md_coffee_stout):
|
||||||
|
"""Test valid recipe mash table."""
|
||||||
|
assert md_coffee_stout.mash == (
|
||||||
|
'Mash\n'
|
||||||
|
'----\n'
|
||||||
|
'| Name | Type | Temperature | Time | Amount |\n'
|
||||||
|
'| -------- | -------- | ----------- | ------ | -------- |\n'
|
||||||
|
'| Infusion | Infusion | 152.0 °F | 60 min | 37.55 lb |'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_write_recipes(md_recipes, tmpdir):
|
def test_write_recipes(md_recipes, tmpdir):
|
||||||
"""Test write_recipes function."""
|
"""Test write_recipes function."""
|
||||||
write_recipes(md_recipes, str(tmpdir))
|
write_recipes(md_recipes, str(tmpdir))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue