Beispiel #1
0
    def get_fermentables(self, json_data: JsonParser) -> iter:
        i = 1
        while (kind := json_data.string_or_none("Malz%d" % i)) is not None:
            kind = clean_kind(kind)

            amount = json_data.float_or_none("Malz%d_Menge" % i)
            if amount is not None:
                unit = json_data.string_or_none("Malz%d_Einheit" % i)
                if unit is not None and unit == 'kg':
                    amount *= 1000

            yield RecipeFermentable(kind_raw=kind, amount=amount)
            i += 1
Beispiel #2
0
    def get_fermentables(self, bs_recipe: BeerSmithNode) -> iter:
        for bs_fermentable in self.get_ingredients_of_type(
                bs_recipe, ['grain']):
            amount = bs_fermentable.float_or_none('amount')
            if amount is not None:
                amount = ounces_to_gramms(amount)

            name = clean_kind(bs_fermentable.string_or_none('name'))

            fermentable = RecipeFermentable()
            fermentable.kind_raw = name
            fermentable.amount = amount
            fermentable.form = self.get_fermentable_form(bs_fermentable)
            fermentable.origin_raw = clean_kind(
                bs_fermentable.string_or_none('origin'))
            fermentable.color_lovibond = bs_fermentable.float_or_none('color')
            fermentable._yield = bs_fermentable.float_or_none('yield')

            # Extra values
            fermentable.set_extra('notes',
                                  bs_fermentable.string_or_none('notes'))

            yield fermentable
Beispiel #3
0
    def get_fermentables(self, beerxml: BeerXMLRecipe) -> iter:
        for beerxml_fermentable in beerxml.fermentables:
            amount = beerxml_fermentable.amount
            if amount is not None:
                amount *= 1000  # convert to grams

            name = clean_kind(beerxml_fermentable.name)

            fermentable = RecipeFermentable()
            fermentable.kind_raw = name
            fermentable.amount = amount
            fermentable.form = self.get_fermentable_form(
                beerxml_fermentable.type)
            fermentable.origin_raw = clean_kind(beerxml_fermentable.origin)
            fermentable.color_lovibond = beerxml_fermentable.color
            fermentable._yield = beerxml_fermentable._yield

            yield fermentable
Beispiel #4
0
 def save_match(self, item: RecipeFermentable, match: Fermentable):
     item.kind = match
     item.save()