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()