minor filepath changes
This commit is contained in:
@@ -5,11 +5,13 @@ from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
file_path = os.getenv("FILE_PATH") + "/checklist.md" if os.getenv("FILE_PATH") else "./checklist.md"
|
||||
checklist_file_path = os.getenv("FILE_PATH") + "/checklist.md" if os.getenv("FILE_PATH") else "./checklist.md"
|
||||
|
||||
ingredients_file_path = "./src/json/ingredients.json"
|
||||
|
||||
def read_json() -> dict:
|
||||
try:
|
||||
with open("./src/json/ingredients.json", "rt") as file:
|
||||
with open(ingredients_file_path, "rt") as file:
|
||||
return json.load(file)
|
||||
except:
|
||||
print("Could not find or read file.")
|
||||
@@ -17,7 +19,7 @@ def read_json() -> dict:
|
||||
|
||||
def update_json(meals: dict) -> None:
|
||||
try:
|
||||
with open("./src/json/ingredients.json", "w") as file:
|
||||
with open(ingredients_file_path, "w") as file:
|
||||
json.dump(meals, file, indent=4)
|
||||
except Exception as e:
|
||||
print(f"Unable to write data to file. {e}")
|
||||
@@ -44,7 +46,7 @@ def combine_ingredients(meals: dict) -> dict:
|
||||
|
||||
def write_checklist(data: dict) -> None:
|
||||
try:
|
||||
with open(file_path, 'w') as checklist:
|
||||
with open(checklist_file_path, 'w') as checklist:
|
||||
for ingredient, details in data.items():
|
||||
s = ingredient + " - " + str(details['quantity'])
|
||||
if details['units'] != None:
|
||||
|
||||
Reference in New Issue
Block a user