minor changes

This commit is contained in:
Nicholas
2025-11-22 16:00:23 -05:00
parent 75cd42ed30
commit 7347b53bfe
2 changed files with 27 additions and 24 deletions

View File

@@ -7,28 +7,29 @@ load_dotenv()
file_path = os.getenv("file_path") if os.getenv("file_path") else "./checklist.md"
def read_json() -> dict | None:
def read_json() -> dict:
try:
with open("./src/json/ingredients.json", "rt") as file:
return json.load(file)
except:
print("Could not find or read file.")
return {}
def update_json(meals: dict):
def update_json(meals: dict) -> None:
try:
with open("./src/json/ingredients.json", "w") as file:
json.dump(meals, file, indent=4)
except Exception as e:
print(f"Unable to write data to file. {e}")
def get_selected_meals(meals: dict) -> dict | None:
def get_selected_meals(meals: dict) -> dict:
meal_json = read_json()
selected_meals = {}
if meal_json:
for meal in meals:
if meal in meal_json:
selected_meals[meal] = meal_json[meal]
return selected_meals
return selected_meals
def combine_ingredients(meals: dict) -> dict:
combined_ingredients = {}