From 688008fb961b7f9763139d6ac711272179a4e14b Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Fri, 10 Dec 2021 15:10:30 -0500 Subject: [spiral emoji] --- lib/xas/message.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lib/xas/message.py (limited to 'lib/xas/message.py') diff --git a/lib/xas/message.py b/lib/xas/message.py new file mode 100644 index 0000000..dc673ef --- /dev/null +++ b/lib/xas/message.py @@ -0,0 +1,22 @@ +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 :: %s" % (self.id, code, status.typeobj.name) + + if status.typeobj.name != status.description: + 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) -- cgit v1.2.3