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