Skip to content

Joes branch #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions data/store1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
"1":
- "mexican"
- "international"
- "gourmet"
- "pasta"
- "pizza dough"
- "pizza sauce"
- "rice"
"2":
- "asain foods"
- "bbq sauce"
- "beans"
- "mayo"
- "mustard"
- "relish"
- "salad dressing"
- "shortening"
- "soups"
- "canned vegetables"
"3":
- "baking needs"
- "baking"
- "bake ware"
- "cake mixes"
- "cake decor"
- "chocolate chips"
- "coconut"
- "cooking oil"
- "flour"
- "canned fruits"
- "gravy"
- "jams/jellies"
- "pudding"
- "salt"
- "spices"
- "stuffing"
- "sugar"
- "peanut butter"
"4":
- "cereal"
- "granola"
- "Honey"
- "oats"
- "pancake mix"
"5":
- "bread"
- "cocoa"
- "coffee"
- "syrup"
- "tea"
"6":
- "juices"
- "seltzer"
"7":
- "cookies"
- "crackers"
- "soda"
"8":
"9":
- "chips"
- "seasonal"
"10":
- "aluminum foil"
- "freezer wrap"
- "napkins"
- "tissues"
"11":
- "matches"
"12":
- "house"
- "mop"
- "broom"
- "cleaning"
"13":
- "nuts"
"14":
- "frozen foods"
78 changes: 0 additions & 78 deletions data/stores.yaml

This file was deleted.

86 changes: 47 additions & 39 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import yaml
import logging
#import wx

#app = wx.App()
Expand All @@ -8,47 +9,54 @@
#app.MainLoop()

fruits_list = []
logging.basicConfig(level=logging.INFO) # Set the logging level (setting it lower will display more messages)

def find_aisle(search_item):
for aisle in fruits_list["aisle"]:
for item in aisle:
print(item)
if search_item == item :
return aisle
return None


with open(r'data/stores.yaml') as file:
for aisle, items in fruits_list.items(): #.iteritems() for python 2
logging.debug("Currently looking at aisle " + str(aisle)) # Send a message to the logger
try: # Try doing the following
for item in items: # For every item in all the items in an aisle
logging.debug("Currently checking item " + str(item).upper() + ", Looking for " + str(search_item).upper()) # log what we're looking for
if str(search_item).upper() == str(item).upper() : # Check if true
logging.info("Found item " + str(item) + " in aisle " + str(aisle)) # Log that we found an item
return aisle # Return the aisle that item exists in
except: # If something above failed
logging.warning("Error, no items in row: " + str(aisle)) # Trow an error
return None # If nothing above worked, return that the item could not be found


with open(r'data/store1.yaml') as file:
fruits_list = yaml.safe_load(file)

print(fruits_list)
print(fruits_list["aisle"]["1"])
list_of_all_things_in_isle_1 = fruits_list["aisle"]["1"]

print(find_aisle("beans"))

#This sets the store location, which has different items in different locations.
count = False
store = input("Where are you shopping?: ")
while count == False:
#if store == "Hannaford" or store == "hannaford":
if store.upper() == "hannaford".upper():
store_items = []
aisle_location = []
count = True
elif "sam".upper() in store.upper():
store_items = []
aisle_location = []
count = True
else:
print ("Sorry, I don't recognize that store, try again.")
store = input("Where are you shopping?: ")

#This sets the items in the shopping list for comparison and sorting.
list_count = int(input("How many items are on your shopping list?: "))
shopping_list = []
shopping_list_final = []
for i in range(list_count):
item = input("Enter item: ")
shopping_list.append(item)
#logging.debug(fruits_list)
#logging.debug(fruits_list["aisle"]["1"])
list_of_all_things_in_isle_1 = fruits_list["1"]

logging.info("Searched for item nuts and found item in: " + str(find_aisle("nuts"))) # Log this

if __name__ == "_main__": # Run only if this is the main file
#This sets the store location, which has different items in different locations.
count = False
store = input("Where are you shopping?: ")
while count == False:
#if store == "Hannaford" or store == "hannaford":
if store.upper() == "hannaford".upper():
store_items = []
aisle_location = []
count = True
elif "sam".upper() in store.upper():
store_items = []
aisle_location = []
count = True
else:
print ("Sorry, I don't recognize that store, try again.")
store = input("Where are you shopping?: ")

#This sets the items in the shopping list for comparison and sorting.
list_count = int(input("How many items are on your shopping list?: "))
shopping_list = []
shopping_list_final = []
for i in range(list_count):
item = input("Enter item: ")
shopping_list.append(item)