diff options
author | Walter Bender <walter.bender@gmail.com> | 2011-11-16 13:35:44 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2011-11-16 13:35:44 (GMT) |
commit | 6b051458f92dda9dc7ba9d6193defe718a7ea5f6 (patch) | |
tree | 7d67bab674fe3fd31975d0ca25bb3b1e26a03734 /exporthtml.py | |
parent | 722223e9d51bde37224ef7cc98657622d2d3e0f6 (diff) |
fixed logic error re no thumbnail image available
Diffstat (limited to 'exporthtml.py')
-rw-r--r-- | exporthtml.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/exporthtml.py b/exporthtml.py index 507f09f..f50db45 100644 --- a/exporthtml.py +++ b/exporthtml.py @@ -14,6 +14,7 @@ import pygtk pygtk.require('2.0') import gtk +from glib import GError import os.path from cgi import escape from gettext import gettext as _ @@ -66,21 +67,28 @@ def save_html(dsobjects, nick, colors, tmp_path): htmlcode += HTML_GLUE['h1'][0] + \ dsobj.metadata['title'] + \ HTML_GLUE['h1'][1] + else: + htmlcode += HTML_GLUE['h1'][0] + \ + _('untitled') + \ + HTML_GLUE['h1'][1] - pixbuf = None - media_object = False try: pixbuf = gtk.gdk.pixbuf_new_from_file_at_size( dsobj.file_path, 800, 600) - key = 'img2' - except: - pixbuf = get_pixbuf_from_journal(dsobj, 300, 225) - key = 'img' + image_key = 'img2' + except(GError, IOError): + try: + pixbuf = get_pixbuf_from_journal(dsobj, 300, 225) + image_key = 'img' + except(GError, IOError): + pixbuf = None if pixbuf is not None: - tmp = HTML_GLUE[key][0] + tmp = HTML_GLUE[image_key][0] tmp += image_to_base64(pixbuf, tmp_path) - tmp += HTML_GLUE[key][1] + tmp += HTML_GLUE[image_key][1] + else: # No image + tmp = '' if 'description' in dsobj.metadata: tmp += '<p class="body">' + dsobj.metadata['description'] + '</p>' |