The beerxml python package is a powerful tool designed to streamline the process of working with BeerXML files, ensuring that specific beer recipes adhere to the BeerXML standard. BeerXML is a widely adopted XML-based standard for representing brewing recipes, allowing brewers to share and exchange their recipes seamlessly.
To install your package, use the following command:
pip install beerxml
The models in this beerxml package have been generated from this beerxml json schema with this command:
datamodel-codegen --input .\schemas\Recipe.json --input-file-type jsonschema --output output.py --snake-case-field --capitalise-enum-members --use-annotated --use-non-positive-negative-number-constrained-types --output-model-type pydantic_v2.BaseModel
Import the BeerxmlParser
class and inject the file content into the class like in the following example:
from beerxml import BeerxmlParser
# Example usage
parser: BeerxmlParser = BeerxmlParser()
with open("path/to/xml.file", "r") as file_content:
recipe = parser.parse(file_content.read())
print(recipe.name)
print(recipe.hops)
print(recipe.fermentables)
print(recipe.yeasts)
We welcome contributions from the community! If you would like to contribute to this project, please follow these guidelines:
If you encounter any issues or have suggestions, please open an issue on our GitHub repository.
- Fork the repository and create a new branch for your contribution.
- Write clear and concise commit messages.
- Include unit tests for your changes
- Submit a pull request, clearly describing the changes you've made and providing any necessary context.
We use the following linters to maintain code quality:
Before submitting a pull request, ensure that your code passes these checks.
All contributions must be accompanied by unit tests using pytest. Test coverage is crucial to ensure the reliability of the codebase.
To run tests locally:
pytest .