diff options
Diffstat (limited to 'lib/xas/message.py')
-rw-r--r-- | lib/xas/message.py | 22 |
1 files changed, 22 insertions, 0 deletions
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) |