[hamster-applet] added __iter__ so that the fact can be serialized in a dict
- From: Toms Baugis <tbaugis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hamster-applet] added __iter__ so that the fact can be serialized in a dict
- Date: Sat, 6 Nov 2010 12:49:42 +0000 (UTC)
commit 2e706732afbcefaf2e60b4b8f28eff5773121b2c
Author: Toms Bauģis <toms baugis gmail com>
Date: Sat Nov 6 12:49:14 2010 +0000
added __iter__ so that the fact can be serialized in a dict
src/hamster/utils/stuff.py | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/src/hamster/utils/stuff.py b/src/hamster/utils/stuff.py
index 97125c4..d874d82 100644
--- a/src/hamster/utils/stuff.py
+++ b/src/hamster/utils/stuff.py
@@ -322,6 +322,21 @@ class Fact(object):
self.end_time = end_time or self.end_time or None
+ def __iter__(self):
+ keys = {
+ 'id': int(self.id),
+ 'activity': self.activity,
+ 'category': self.category,
+ 'description': self.description,
+ 'tags': [tag.encode("utf-8").strip() for tag in self.tags.split(",")],
+ 'date': calendar.timegm(self.date.timetuple()),
+ 'start_time': calendar.timegm(self.start_time.timetuple()),
+ 'end_time': calendar.timegm(self.end_time.timetuple()) if self.end_time else "",
+ 'delta': self.delta.seconds + self.delta.days * 24 * 60 * 60 #duration in seconds
+ }
+ return iter(keys.items())
+
+
def serialized_name(self):
res = self.activity
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]