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
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