Beispiel #1
0
    def get_yeasts(self, beerxml: BeerXMLRecipe) -> iter:
        for beerxml_yeast in beerxml.yeasts:
            amount = beerxml_yeast.amount
            if amount is not None:
                amount *= 1000  # convert to grams/milliliters

            name = clean_kind(beerxml_yeast.name)
            yeast = RecipeYeast(kind_raw=name)

            # Handle numeric product ids
            product_id = beerxml_yeast.product_id
            if isinstance(product_id, int):
                product_id = str(product_id)
            if isinstance(product_id, float):
                if round(product_id) == product_id:
                    product_id = str(round(product_id))
                else:
                    product_id = str(product_id).strip()

            yeast.lab = beerxml_yeast.laboratory
            yeast.product_id = product_id
            yeast.form = self.get_yeast_form(beerxml_yeast.form)
            yeast.type = self.get_yeast_type(beerxml_yeast.type)
            yeast.amount = amount
            yeast.amount_is_weight = beerxml_yeast.amount_is_weight
            yeast.min_attenuation = beerxml_yeast.attenuation
            yeast.max_attenuation = beerxml_yeast.attenuation

            # Extra values
            yeast.set_extra('min_temperature', beerxml_yeast.min_temperature)
            yeast.set_extra('max_temperature', beerxml_yeast.max_temperature)
            yeast.set_extra(
                'flocculation',
                self.get_yeast_flocculation(beerxml_yeast.flocculation))

            yield yeast
Beispiel #2
0
    def get_yeasts(self, bs_recipe: BeerSmithNode) -> iter:
        for bs_yeast in self.get_ingredients_of_type(bs_recipe, ['yeast']):
            name = clean_kind(bs_yeast.string_or_none('name'))
            yeast = RecipeYeast(kind_raw=name)

            yeast.lab = bs_yeast.string_or_none('lab')
            yeast.product_id = bs_yeast.string_or_none('product_id')
            yeast.form = self.get_yeast_form(bs_yeast)
            yeast.type = self.get_yeast_type(bs_yeast)
            yeast.min_attenuation = bs_yeast.float_or_none('min_attenuation')
            yeast.max_attenuation = bs_yeast.float_or_none('max_attenuation')

            # Extra values
            notes = bs_yeast.string_or_none('notes')
            min_temp = bs_yeast.float_or_none('min_temp')
            max_temp = bs_yeast.float_or_none('max_temp')
            yeast.set_extra('notes', None if notes is None else notes.strip())
            yeast.set_extra(
                'min_temperature',
                None if min_temp is None else fahrenheit_to_celsius(min_temp))
            yeast.set_extra(
                'max_temperature',
                None if max_temp is None else fahrenheit_to_celsius(max_temp))
            yeast.set_extra('flocculation',
                            self.get_yeast_flocculation(bs_yeast))
            yeast.set_extra('best_for', bs_yeast.string_or_none('best_for'))

            yield yeast
Beispiel #3
0
 def get_yeasts(self, json_data: JsonParser) -> iter:
     yeast_kind = json_data.string_or_none('Hefe')
     if yeast_kind is not None:
         yield RecipeYeast(kind_raw=yeast_kind)
Beispiel #4
0
 def save_match(self, item: RecipeYeast, match: Yeast):
     item.kind = match
     item.save()