-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to pass complete style into __init__ constructor? #4
Comments
Hello, Thanks for the issue. You're absolutely right there is no way to implement a dict style in the current state. |
I started to work on a PR, but after looking through the code more, I decided this project is not for me. All I needed was to parse a BSMX recipe/equipment file to convert it to readable YAML. For that I was happy to use Box. (Still struggling to determine all of the various enumerations used in BSMX, but nothing helps that when it's not documented anywhere.) I would love to see this become more of a full-featured schema, and then this code could just define a schema with Cerebus/jsonschema/schema and then load yaml and validate it. That spec is the difficult part, but once done it could be implemented in XML/YAML whatever. A custom library like this could also implement user-friendly YAML tag features like accepting unit input that gets converted into a unit structure for interchange. Off the top of my head... thinking of something like this: fermentables:
- name: Pale 2-row Malt:
type: Grain
amount: !Pounds 5.0
yield: !Percent 73.4
color: !EBC 3.0 This would parsed to: fermentables:
- name: Pale 2-row Malt:
type: Grain
amount: {value: 5.0, unit: pounds}
yield: {value: 73.4, unit: percentage}
color: {value: 3.0, unit: ebc} |
Hello, The main purpose of this code was to simply write and read beer recipes for humans using a less verbose language than beerxml but remaining compatible with it. It was never an intent to make a full-featured schema with validation nor replace beerxml which is widely used. However since all units are fixed in beerxml, your idea of converting the units using the library is very interesting. I should create a ticket about it. Thanks for the issue, I will merge a fix soon. |
I trying to understand how to pass in a dict for the style, instead of just the name, but I can't figure it out. If I pass in
style={"name": "American Wheat or Rye Beer", "category": "Light Hybrid Beer", ...etc...}
I get:KeyError: 'style'
from this line:pybeeryaml/pybeeryaml/recipe.py
Line 61 in 277f427
As far as I can tell, these two lines make it impossible to pass in a complex style, because if style is a dict, then it tries to load in style from
**data["style"]
(Pythonic style, that should probably be**kwargs
!) parameters, but it won't be there because it was passed in as a named parameter.Instead I believe it should be this:
The text was updated successfully, but these errors were encountered: