From df2798eafb3ff0201bb8c33f8d80f1cbcc32944e Mon Sep 17 00:00:00 2001 From: Hemna Date: Sat, 24 Feb 2024 14:27:39 -0500 Subject: [PATCH] Added iterator to objectstore Since the objectstore mixin uses a iterable to store it's data, it was easy to add an __iter__ to the objectstore class itself. --- aprsd/utils/objectstore.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/aprsd/utils/objectstore.py b/aprsd/utils/objectstore.py index b71ee7a..dec9dca 100644 --- a/aprsd/utils/objectstore.py +++ b/aprsd/utils/objectstore.py @@ -28,6 +28,9 @@ class ObjectStoreMixin: def __len__(self): return len(self.data) + def __iter__(self): + return iter(self.data) + def get_all(self): with self.lock: return self.data @@ -96,11 +99,15 @@ class ObjectStoreMixin: LOG.debug( f"{self.__class__.__name__}::Loaded {len(self)} entries from disk.", ) - LOG.debug(f"{self.data}") + #LOG.debug(f"{self.data}") + else: + LOG.debug(f"{self.__class__.__name__}::No data to load.") except (pickle.UnpicklingError, Exception) as ex: LOG.error(f"Failed to UnPickle {self._save_filename()}") LOG.error(ex) self.data = {} + else: + LOG.debug(f"{self.__class__.__name__}::No save file found.") def flush(self): """Nuke the old pickle file that stored the old results from last aprsd run."""