diff options
Diffstat (limited to 'src/jarabe/journal/expandedentry.py')
-rw-r--r-- | src/jarabe/journal/expandedentry.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/jarabe/journal/expandedentry.py b/src/jarabe/journal/expandedentry.py index 725c0f9..fe2f320 100644 --- a/src/jarabe/journal/expandedentry.py +++ b/src/jarabe/journal/expandedentry.py @@ -36,6 +36,7 @@ from jarabe.journal.palettes import ObjectPalette, BuddyPalette from jarabe.journal import misc from jarabe.journal import model + class Separator(hippo.CanvasBox, hippo.CanvasItem): def __init__(self, orientation): hippo.CanvasBox.__init__(self, @@ -46,6 +47,7 @@ class Separator(hippo.CanvasBox, hippo.CanvasItem): else: self.props.box_height = style.LINE_WIDTH + class BuddyList(hippo.CanvasBox): def __init__(self, buddies): hippo.CanvasBox.__init__(self, xalign=hippo.ALIGNMENT_START, @@ -61,6 +63,7 @@ class BuddyList(hippo.CanvasBox): hbox.append(icon) self.append(hbox) + class ExpandedEntry(hippo.CanvasBox): def __init__(self): hippo.CanvasBox.__init__(self) @@ -209,9 +212,7 @@ class ExpandedEntry(hippo.CanvasBox): height = style.zoom(240) box = hippo.CanvasBox() - if self._metadata.has_key('preview') and \ - len(self._metadata['preview']) > 4: - + if len(self._metadata.get('preview', '')) > 4: if self._metadata['preview'][1:4] == 'PNG': preview_data = self._metadata['preview'] else: @@ -280,10 +281,15 @@ class ExpandedEntry(hippo.CanvasBox): def _format_date(self): if 'timestamp' in self._metadata: - timestamp = float(self._metadata['timestamp']) - return time.strftime('%x', time.localtime(timestamp)) - else: - return _('No date') + try: + timestamp = float(self._metadata['timestamp']) + except (ValueError, TypeError): + logging.warning('Invalid timestamp for %r: %r', + self._metadata['uid'], + self._metadata['timestamp']) + else: + return time.strftime('%x', time.localtime(timestamp)) + return _('No date') def _create_buddy_list(self): @@ -301,8 +307,7 @@ class ExpandedEntry(hippo.CanvasBox): vbox.append(text) - if self._metadata.has_key('buddies') and \ - self._metadata['buddies']: + if self._metadata.get('buddies'): buddies = simplejson.loads(self._metadata['buddies']).values() vbox.append(BuddyList(buddies)) return vbox |