food-explorer / utils /config_utils.py
Ivan Herrera
fix config dropdown
111ca2d
Raw
History Blame Contribute Delete
3.38 kB
import json
food_explorer_config_path = "food_explorer_config.json"
def load_all_configs():
with open(food_explorer_config_path, "r") as file:
return json.load(file)
def save_config(config_name, config_data):
configs = load_all_configs()
configs[config_name] = config_data
with open(food_explorer_config_path, "w") as file:
json.dump(configs, file, indent=4)
return [key for key in configs.keys() if key != "current_config"]
def set_current_config(config_name):
configs = load_all_configs()
configs["current_config"] = config_name
with open(food_explorer_config_path, "w") as file:
json.dump(configs, file, indent=4)
def load_current_config():
configs = load_all_configs()
current_config_name = configs.get("current_config", "Default")
return configs[current_config_name]
# Function to update diet information when a selection is made
def update_diet_info(selection):
diet_descriptions = {
"Balanced Diet": "Description: A diet that provides a well-rounded intake of macronutrients to support overall health, energy levels, and daily activities.\n\nMacro Percentages:\nCarbohydrates: 50%\nProtein: 20%\nFat: 30%\n\nKey Foods: Whole grains, lean meats, fish, dairy, legumes, vegetables, fruits, nuts, seeds, and healthy fats.",
"Zone Diet": "Description: The Zone Diet focuses on balancing macronutrients to control insulin levels and reduce inflammation.\n\nMacro Percentages:\nFat: 30%\nProtein: 30%\nCarbohydrates: 40%\n\nKey Foods: Lean meats, fish, eggs, fruits, vegetables, whole grains, healthy fats.",
"Ketogenic Diet (Keto)": "Description: A high-fat, low-carb diet designed to induce ketosis.\n\nMacro Percentages:\nFat: 70-80%\nProtein: 15-25%\nCarbohydrates: 5-10%\n\nKey Foods: Fatty meats, avocados, nuts, seeds, full-fat dairy, low-carb vegetables.",
"Vegan Diet": "Description: A plant-based diet that excludes all animal products.\n\nMacro Percentages:\nCarbohydrates: 50-65%\nProtein: 10-20%\nFat: 20-30%\n\nKey Foods: Fruits, vegetables, grains, legumes, nuts, seeds.",
"Mediterranean Diet": "Description: A heart-healthy diet inspired by Mediterranean eating habits.\n\nMacro Percentages:\nCarbohydrates: 45-55%\nProtein: 15-20%\nFat: 25-35%\n\nKey Foods: Olive oil, fish, whole grains, fruits, vegetables, nuts.",
"Paleo Diet": "Description: A diet based on presumed ancient human eating habits.\n\nMacro Percentages:\nCarbohydrates: 20-40%\nProtein: 25-35%\nFat: 30-40%\n\nKey Foods: Lean meats, fish, eggs, fruits, vegetables, nuts, seeds.",
"Low-Carb Diet": "Description: A diet that restricts carbohydrate intake.\n\nMacro Percentages:\nCarbohydrates: 10-30%\nProtein: 30-40%\nFat: 30-50%\n\nKey Foods: Lean meats, fish, eggs, non-starchy vegetables, healthy fats.",
"High-Protein Diet": "Description: A diet emphasizing protein intake.\n\nMacro Percentages:\nCarbohydrates: 20-30%\nProtein: 30-40%\nFat: 20-30%\n\nKey Foods: Lean meats, fish, eggs, dairy, legumes.",
"Vegetarian Diet": "Description: A diet that excludes meat but may include dairy and eggs.\n\nMacro Percentages:\nCarbohydrates: 50-60%\nProtein: 15-25%\nFat: 20-30%\n\nKey Foods: Fruits, vegetables, grains, legumes, dairy, eggs."
}
return diet_descriptions.get(selection, "Please select a dietary approach to see information.")