A simple BeerXML parser for Python
Parses all recipes within a BeerXML file and returns Recipe
objects containing all ingredients,
style information and metadata. OG, FG, ABV and IBU are calculated from the ingredient list. (your
milage may vary)
pip install pybeerxml
from pybeerxml import Parser
path_to_beerxml_file = "/tmp/SimcoeIPA.beerxml"
parser = Parser()
recipes = parser.parse(path_to_beerxml_file)
for recipe in recipes:
# some general recipe properties
print(recipe.name)
print(recipe.brewer)
# calculated properties
print(recipe.og)
print(recipe.fg)
print(recipe.ibu)
print(recipe.abv)
# iterate over the ingredients
for hop in recipe.hops:
print(hop.name)
for fermentable in recipe.fermentables:
print(fermentable.name)
for yeast in recipe.yeasts:
print(yeast.name)
for misc in recipe.miscs:
print(misc.name)
Unit tests can be run with PyTest:
python -m pytest tests
Community contributions are welcome.
Some kind of virtual environment for Python is recommended. Consider venv
, conda
or similar. Dependency management is handled through Poetry:
pip install poetry
poetry install
Make sure to Test, Lint, Format, & Type-Check your code before sending a pull request:
python -m pytest tests
python -m black pybeerxml tests/*.py
python -m pylint pybeerxml tests/*.py
python -m mypy pybeerxml tests/*.py
MIT