from collections import Counter from typing import List from mesa.visualization.modules import TextElement from data.Order import Order class DisplayOrderList(TextElement): def __init__(self, attr_name): ''' Create a new text attribute element. Args: attr_name: The name of the attribute to extract from the model. Example return: "happy: 10" ''' self.attr_name = attr_name def render(self, model): val = getattr(model, self.attr_name) res = "" if val is not None: orderList: List[Order] = val res = self.attr_name + ":
    " for o in orderList: if o is None: continue itemList = map(lambda x: x.real_type, o.items) itemCounter = Counter(itemList) item_str = "" res += f"
  1. items: {item_str} priority: {o.priority}
    Client: {vars(o.client_params)}
  2. " res += "
" return res