summaryrefslogtreecommitdiffstats
path: root/lib/xas/status.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xas/status.py')
-rw-r--r--lib/xas/status.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/xas/status.py b/lib/xas/status.py
index 720d93f..1465616 100644
--- a/lib/xas/status.py
+++ b/lib/xas/status.py
@@ -12,9 +12,9 @@ class ErrorType(StatusType):
pass
class Status():
- def __init__(self, id: int, typeof: StatusType, description: str):
+ def __init__(self, id: int, typeobj: StatusType, description: str):
self.id = id
- self.typeof = typeof
+ self.typeobj = typeobj
self.description = description
def __str__(self):
@@ -39,18 +39,21 @@ class Database():
def load_types(self):
targets = {
- "xas_status_type": self.statusTypes,
- "xas_error_type": self.errorTypes
+ "xas_status_type": (StatusType, self.statusTypes),
+ "xas_error_type": (ErrorType, self.errorTypes)
}
for table in targets.keys():
- target = targets[table]
+ typeof = targets[table][0]
+ target = targets[table][1]
cr = self.db.cursor()
cr.execute(f"select id, name from {table}")
for row in cr.fetchall():
- target[row['id']] = row['name']
+ typeobj = typeof(row['id'], row['name'])
+
+ target[typeobj.id] = typeobj
def status_type(self, id: int):
return self.statusTypes[id]
@@ -60,19 +63,21 @@ class Database():
def load_statuses(self):
targets = {
- "xas_status": (Status, self.statuses),
- "xas_error": (Error, self.errors)
+ "xas_status": (Status, self.statusTypes, self.statuses),
+ "xas_error": (Error, self.errorTypes, self.errors)
}
for table in targets.keys():
typeof = targets[table][0]
- target = targets[table][1]
+ types = targets[table][1]
+ target = targets[table][2]
cr = self.db.cursor()
cr.execute(f"select id, type_id, description from {table}")
for row in cr.fetchall():
- obj = typeof(row['id'], row['type_id'], row['description'])
+ typeobj = types[row['type_id']]
+ obj = typeof(row['id'], types[row['type_id']], row['description'])
target[obj.id] = obj