Skip to content
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

store.get_menu() raised an exception #115

Open
DrLatency opened this issue Dec 12, 2020 · 3 comments
Open

store.get_menu() raised an exception #115

DrLatency opened this issue Dec 12, 2020 · 3 comments

Comments

@DrLatency
Copy link

I was just going through the tutorial but can't get store.get_menu() to work.

My code:

from pizzapi import *
customer = Customer('Donald', 'Trump', 'donald@whitehouse.gov', '2024561111')
address = Address('2175 S 11th Ave', 'Bozeman', 'MT', '59715')
store = address.closest_store()
menu = store.get_menu()

results in terminal:

from pizzapi import *
customer = Customer('Donald', 'Trump', 'donald@whitehouse.gov', '2024561111')
address = Address('2175 S 11th Ave', 'Bozeman', 'MT', '59715')
store = address.closest_store()
menu = store.get_menu()
customer = Customer('Donald', 'Trump', 'donald@whitehouse.gov', '2024561111')
address = Address('2175 S 11th Ave', 'Bozeman', 'MT', '59715')
store = address.closest_store()
menu = store.get_menu()
Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pizzapi/store.py", line 24, in get_menu
menu = Menu(response, self.country)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pizzapi/menu.py", line 50, in init
self.root_categories[key] = self.build_categories(value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pizzapi/menu.py", line 62, in build_categories
new_subcategory = self.build_categories(subcategory, category)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pizzapi/menu.py", line 66, in build_categories
raise Exception('PRODUCT NOT FOUND: %s %s' % (product_code, category.code))
Exception: PRODUCT NOT FOUND: 9418 CouponPizza

@milan-stoj
Copy link

The following work around seems to do the trick.

Inside of menu.py - comment out line 66 and add a continue statement when the conditional is triggered:

def build_categories(self, category_data, parent=None):
    category = MenuCategory(category_data, parent)
    for subcategory in category_data['Categories']:
        new_subcategory = self.build_categories(subcategory, category)
        category.subcategories.append(new_subcategory)
    for product_code in category_data['Products']:
        if product_code not in self.menu_by_code:
            # raise Exception('PRODUCT NOT FOUND: %s %s' % (product_code, category.code))
            continue
        product = self.menu_by_code[product_code]
        category.products.append(product)
        product.categories.append(category)
    return category

Instead of raising an exception when a product category is not found, it will just skip adding that product category and continue building.

LarveyOfficial added a commit to LarveyOfficial/pizzapi that referenced this issue Apr 15, 2021
tdickman added a commit to fold-team/pizzapi that referenced this issue May 18, 2021
@anask1234
Copy link

i have the same issue ...

@brainharrington
Copy link

Getting error Exception: PRODUCT NOT FOUND: 5199 CouponPizza as well

Going to the try the continue idea above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants