diff options
Diffstat (limited to 'py/xas/message.py')
-rw-r--r-- | py/xas/message.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/py/xas/message.py b/py/xas/message.py new file mode 100644 index 0000000..e297e40 --- /dev/null +++ b/py/xas/message.py @@ -0,0 +1,24 @@ +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) |