aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2022-03-28 18:17:40 +0200
committerThéo de la Hogue2022-03-28 18:17:40 +0200
commitb5220837d67895fa3a6f2be208711cc0e0396718 (patch)
tree64c941e585c3d3e2a1af6a7ed0981196eb364527 /src
parent5f2eb6ba93328231f45b3f7bcf127ccf34851a0c (diff)
downloadargaze-b5220837d67895fa3a6f2be208711cc0e0396718.zip
argaze-b5220837d67895fa3a6f2be208711cc0e0396718.tar.gz
argaze-b5220837d67895fa3a6f2be208711cc0e0396718.tar.bz2
argaze-b5220837d67895fa3a6f2be208711cc0e0396718.tar.xz
Serialising DictObject and TimeStampedBuffer
Diffstat (limited to 'src')
-rw-r--r--src/argaze/DataStructures.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/argaze/DataStructures.py b/src/argaze/DataStructures.py
index 2fd691b..5648c0e 100644
--- a/src/argaze/DataStructures.py
+++ b/src/argaze/DataStructures.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import collections
+import json
class DictObject():
"""Convert dictionnary into object"""
@@ -13,6 +14,9 @@ class DictObject():
def __getitem__(self, key):
return self.__dict__[key]
+ def __str__(self):
+ return json.dumps({key: self.__dict__[key] for key in self.__dict__.keys()}, default=vars)
+
def type(self):
return self.__type
@@ -46,6 +50,9 @@ class TimeStampedBuffer(collections.OrderedDict):
super().__setitem__(key, value)
+ def __str__(self):
+ return json.dumps(self, default=vars)
+
def pop_first(self):
"""Easing FIFO access mode"""
return self.popitem(last=False) \ No newline at end of file