class Formatter(): def __init__(self, id: int, db): self.id = id self.db = db def fmt(self, lookup, code, text=None): status = lookup(code) output = "%04d :: Code %03d" % (self.id, code) if status.typeobj.name == status.description: output += " :: " + status.typeobj.name else: output += " :: " + status.description if text is not None: output += " :: " + text return output def message(self, code, text=None): return self.fmt(self.db.status, code, text) def error(self, code, text=None): return self.fmt(self.db.error, code, text)