Ejemplo n.º 1
0
    def save_match(self, item: Recipe, style: Style):
        if not self.is_within_limits('abv', item, style):
            style = None
        elif not self.is_within_limits('ibu', item, style):
            style = None
        elif not self.is_within_limits('srm', item, style):
            style = None

        item.style = style
        item.save()
Ejemplo n.º 2
0
    def parse_recipe(self, recipe: Recipe, beerxml: BeerXMLRecipe) -> None:
        recipe.name = str(beerxml.name)
        recipe.author = str(beerxml.brewer)

        # Characteristics
        recipe.style_raw = str(beerxml.style.name)
        recipe.extract_efficiency = beerxml.efficiency
        recipe.og = beerxml.og
        recipe.fg = beerxml.fg
        recipe.abv = self.get_abv(beerxml)
        recipe.ibu = beerxml.ibu
        (recipe.srm, recipe.ebc) = self.get_srm_ebc(beerxml)

        # Mashing
        (recipe.mash_water, recipe.sparge_water) = self.get_mash_water(beerxml)

        # Boiling
        recipe.cast_out_wort = beerxml.batch_size
        recipe.boiling_time = beerxml.boil_time
Ejemplo n.º 3
0
 def __init__(self) -> None:
     self.recipe = Recipe()
     self.fermentables = []
     self.hops = []
     self.yeasts = []
Ejemplo n.º 4
0
    def parse_recipe(self, recipe: Recipe, json_data: JsonParser):
        recipe.name = json_data.string_or_none('Name')
        recipe.author = json_data.string_or_none('Autor')
        date_created = json_data.string_or_none('Datum')
        if date_created is not None:
            recipe.created = datetime.strptime(date_created, '%d.%m.%Y')

        # Characteristics
        recipe.style_raw = json_data.string_or_none('Sorte')
        recipe.extract_efficiency = json_data.float_or_none('Sudhausausbeute')
        recipe.abv = json_data.float_or_none('Alkohol')
        recipe.ebc = json_data.int_or_none('Farbe')
        recipe.ibu = json_data.int_or_none('Bittere')
        recipe.original_plato = json_data.float_or_none('Stammwuerze')
        recipe.final_plato = self.get_final_plato(json_data, recipe)

        # Mashing
        recipe.mash_water = json_data.float_or_none('Infusion_Hauptguss')
        recipe.sparge_water = json_data.float_or_none('Nachguss')

        # Boiling
        recipe.cast_out_wort = json_data.int_or_none('Ausschlagswuerze')
        recipe.boiling_time = json_data.int_or_none('Kochzeit_Wuerze')

        return recipe
Ejemplo n.º 5
0
    def parse_recipe(self, recipe: Recipe, bs_recipe: BeerSmithNode) -> None:
        recipe.name = bs_recipe.string_or_none('name')
        recipe.author = bs_recipe.string_or_none('brewer')
        creation_date = bs_recipe.string_or_none('date')

        if creation_date is None or creation_date == '1969-12-31':
            creation_date = bs_recipe.string_or_none('last_modified')

        # Style
        bs_style = bs_recipe.get_child('style')
        if bs_style:
            recipe.style_raw = clean_kind(bs_style.string_or_none('name'))

        # Recipe
        recipe.og = bs_recipe.float_or_none('og_measured')
        recipe.fg = bs_recipe.float_or_none('fg_measured')
        if recipe.og == 1.046 and recipe.fg == 1.010:
            # These seem to be default values, so they're meaningless
            recipe.og = None
            recipe.fg = None

        (recipe.mash_water,
         recipe.sparge_water) = self.get_mash_water(bs_recipe)

        # Equipment values
        cast_out_ounces = None
        bs_equipment = bs_recipe.get_child('equipment')
        if bs_equipment:
            if creation_date is None or creation_date == '1969-12-31':
                creation_date = bs_equipment.string_or_none('last_modified')
            recipe.boiling_time = bs_equipment.float_or_none('boil_time')
            recipe.extract_efficiency = bs_equipment.float_or_none(
                'efficiency')
            cast_out_ounces = bs_equipment.float_or_none('batch_vol')

        if recipe.extract_efficiency is None:
            recipe.extract_efficiency = bs_recipe.float_or_none(
                'old_efficiency')

        # Boiling
        if cast_out_ounces is None or cast_out_ounces == 0.0:
            cast_out_ounces = bs_recipe.float_or_none('volume_measured')
        if cast_out_ounces is None or cast_out_ounces == 0.0:
            cast_out_ounces = bs_recipe.float_or_none('final_vol_measured')
        if cast_out_ounces == 0.0:
            cast_out_ounces = None

        recipe.cast_out_wort = fluid_ounces_to_liters(
            cast_out_ounces) if cast_out_ounces is not None else None

        # Hopefully we've found a creation date
        if creation_date is not None and creation_date != '1969-12-31':
            try:
                recipe.created = datetime.strptime(creation_date, '%Y-%m-%d')
            except ValueError:
                pass
Ejemplo n.º 6
0
 def save_match(self, item: Recipe, match: Style):
     item.style = match
     item.save()