Skip to content
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

Retrieve original values for ibu/fg/og/abv/color + Extra fields #20

Merged
merged 10 commits into from
Sep 29, 2020

Conversation

scheb
Copy link
Contributor

@scheb scheb commented Sep 15, 2020

As discussed in #17 this is adding the ability to retrieve the original values from the recipe XML.

ibu/fg/og/abv/color properties:

  • Now return the original value from the recipe XML, if present
  • Otherwise they'll return the calculated value

*_calculated properties:

  • return the respective value from calculation only, so these behave exactly the same as before

Other things to note:

  • Debug messages are sent when it falls back to the
  • Extracted a gravity_to_plato helper function to reduce code duplication
  • I've recognized there was a bug when data from <MASH> is mapped to the object. nodes_to_object was used instead of node_to_object. I fixed that. I took the occasion to add some extra fields to the Mash class and added test cases.
  • Added extra fields from the BeerXML spec for hops and fermentables

@scheb scheb changed the title Retrieve original values for ibu/fg/og/abv/color + Mash fields Retrieve original values for ibu/fg/og/abv/color + Extra fields Sep 21, 2020
@hotzenklotz
Copy link
Owner

@scheb Thanks for the PR. The changes look good to me.

Triggered by your earlier PRs I took some time to clean up the code base, make the move to Python 3 and add more linting, formatting, publishing tasks for CI using GitHub Actions. This, plus your previous PRs, were released as version 2.0.0. Do you mind, rebasing/merging your PRs against the current master branch?
Alternatively, let me know and I can take care of the conflict resolving. Thanks.

@scheb
Copy link
Contributor Author

scheb commented Sep 28, 2020

Ok, I'll look into this.

Is it itended that mypy is disabled in the Github actions? https://github.com/hotzenklotz/pybeerxml/actions/runs/276410625/workflow#L40-L43

Readme says I should run it and it displays quite some errors. Are you aware of this?

@hotzenklotz
Copy link
Owner

hotzenklotz commented Sep 28, 2020

Ok, I'll look into this.

Is it itended that mypy is disabled in the Github actions? https://github.com/hotzenklotz/pybeerxml/actions/runs/276410625/workflow#L40-L43

Readme says I should run it and it displays quite some errors. Are you aware of this?

Hahaha, you are vigilant as ever. Yes, I am aware. I had some trouble with these errors but I have fixed all typing issue by now. I also re-enable mypy as part of the CI. Just pushed the latest changes. Please pull to refresh.

@scheb
Copy link
Contributor Author

scheb commented Sep 28, 2020

Alright, will update the PR later.

Btw, since you seem to be interested in beers, here's the project I'm working on, that I'm using your library for: https://www.beer-analytics.com/

@scheb
Copy link
Contributor Author

scheb commented Sep 28, 2020

Updated. I had to remove the "set_" from the setter methods because otherwise the recipe values wouldn't be set.

Copy link
Owner

@hotzenklotz hotzenklotz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the changes/new features look good. Do you mind running another pass of the linter and formatter. (Looks like the tests were not covered. Perhaps I should move them within the pybeerxmldirectory.)

@@ -25,6 +27,18 @@ def __init__(self):
self._yield: Optional[float] = None
self.color: Optional[float] = None
self._add_after_boil: Optional[bool] = None # Should be Bool
self.version: Optional[int] = None
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason, why this is an int? What about versions like 1.2 or something crazy. (I haven't really seen anyone using the version property anyway)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec says it's an int: http://www.beerxml.com/beerxml.htm

But I wouldn't mind to make it a Text for better compatibility. What do you think?

pybeerxml/recipe.py Show resolved Hide resolved
pybeerxml/utils.py Outdated Show resolved Hide resolved
assert floor(recipe.ibu) == 25
assert round(recipe.abv, 2) == 5.35
# should have mashing base information
assert(type(recipe.mash) is Mash)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure PyLint will not like this. Probably:

Suggested change
assert(type(recipe.mash) is Mash)
assert isinstance(recipe.mash, Mash)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change it. I also executed pylint against the tests folder and it showing some issues unrelated to the PR. It kept it as-is because I don't know how you want to deal with those things.

Updated the readme so that the commands include the tests folder.

assert round(recipe.abv, 2) == 5.35
# should have mashing base information
assert(type(recipe.mash) is Mash)
assert (recipe.mash.name == "Single Step")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess all the parentheses here can be omitted. black should take care of that.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied the black code style to the tests folder and updated the readme so that the commands include the tests folder.

@hotzenklotz hotzenklotz merged commit 054a111 into hotzenklotz:master Sep 29, 2020
@hotzenklotz
Copy link
Owner

Thanks again for the excellent pull request. Released as version 2.1.0.

We definitely need to hangout for a beer or homebrew at some point.

@scheb
Copy link
Contributor Author

scheb commented Sep 29, 2020

Awesome, thank you!

Yea we should have a beer at some point, I've seen your company is in Potsdam, that's no so far from Berlin ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants