hhursev / recipe-scrapers

Python package for scraping recipes data
MIT License
1.66k stars 514 forks source link

Updates get_yields util functionality to handle additional metrics #963

Closed jknndy closed 8 months ago

jknndy commented 8 months ago

Adds functionality to the get_yields function to handle cases where the "serving" metric is dozen (#960) or batches.

This may be an unwanted functionality in which case we can just close this without merge but wanted to take a shot at addressing the bug report but if this is something that could be beneficial going forward it could be expanded to handle piece(s), jar(s), cup(s), slice(s), etc...

Resolves #960

hhursev commented 8 months ago

Can you try to code it with а const called RECIPE_YIELD_TYPES for example?

Something like:

RECIPE_YIELD_TYPES = (
    "dozen",
    "batch",
    "cake",
    "sandwich",
    "buns",
    # ..etc
)

that follow up devs can easily extend

jknndy commented 8 months ago

Changed over to using the constant list as recommended, the change seems to be working as intended as a few test cases required updates.

hhursev commented 8 months ago

Me like it.. a lot :)