# This file is a part of Teflon. class Format(object): pass class Message(object): def __init__(self, contents: list): self.contents = contents self.server = None class Cell(object): def __init__(self, content: str, args=None): self.content = content self.args = args or [] def add_arg(self, arg): self.args.append(arg) class Row(object): def __init__(self, cells=None): self._cells = cells or [] def add_cell(self, cell: Cell): self._cells.append(cell) def get_cells(self) -> list: return self._cells class TableFormat(Format): def __init__(self, rows: int, cols: int, rows_=None): self.rows = rows self.cols = cols self._rows = rows_ or [] def add_row(self, row: Row): self._rows.append(row) def get_rows(self) -> list: return self._rows class Text(object): def __init__(self, content, args=None): self.content = content self.args = args or [] def add_arg(self, arg): self.args.append(arg) class LineFormat(Format): def __init__(self, text=None): self.text = text or [] def add_text(self, text): self.text.append(text) class Content(object): def __init__(self, head: str = "", body: str = "", footer: str ="\n"): self.head = head # body is a list of Body joined with EOL self.body = body self.footer = footer class Connection(object): """ Common connection interface """ def __init__(self, name: str): self.name = name self._notify_methods = [] def set_notify_methods(self, methods: list): self._notify_methods = methods def get_notify_methods(self) -> list: return self._notify_methods def connect(self): raise NotImplementedError("Method should be overridden") def get_executor(self): raise NotImplementedError("Method should be overridden") def disconnect(self): raise NotImplementedError("Method should be overridden")