summaryrefslogtreecommitdiffstats
path: root/lib/xas/message.py
diff options
context:
space:
mode:
authorXANTRONIX Development2021-12-10 15:10:30 -0500
committerXANTRONIX Development2021-12-10 15:10:30 -0500
commit688008fb961b7f9763139d6ac711272179a4e14b (patch)
tree33f31f1ceda316f7972c6855a476731dca2ed5ff /lib/xas/message.py
parentb0995cdbe3f5ea282fdb3b3c01c69de9125e2ff2 (diff)
downloadxas-688008fb961b7f9763139d6ac711272179a4e14b.tar.gz
xas-688008fb961b7f9763139d6ac711272179a4e14b.tar.bz2
xas-688008fb961b7f9763139d6ac711272179a4e14b.zip
[spiral emoji]
Diffstat (limited to 'lib/xas/message.py')
-rw-r--r--lib/xas/message.py22
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)