You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
866 B

2 years ago
import yaml
class Order:
items = list()
menu = dict()
@staticmethod
def load_menu():
with open("../data/menu.yml", "r") as stream:
Order.menu = yaml.safe_load(stream)['items']
@staticmethod
def list_options():
return [option['name']for option in Order.menu]
@staticmethod
def add_item(item_name):
Order.items.append(item_name)
@staticmethod
def get_string():
menu_as_dict = {x['name']: x for x in Order.menu}
__items = list(map(lambda x: menu_as_dict[x], Order.items))
output = [f"**{x['name']}**\n{x['description']}" for x in __items]
output = '\n'.join(output)
return output
@staticmethod
def remove_latest_item():
Order.items = Order.items[:-1]
@staticmethod
def clear_all_items():
Order.items = list()