changeset 650:cd3309f76490

macro: PdfList, issue witout any meta solved
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Fri, 02 Oct 2015 11:17:32 +0200
parents 4b31e0f1bcc8
children 8abf42ff06e3
files data/plugin/macro/PdfList.py
diffstat 1 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/macro/PdfList.py	Fri Oct 02 08:44:15 2015 +0200
+++ b/data/plugin/macro/PdfList.py	Fri Oct 02 11:17:32 2015 +0200
@@ -92,7 +92,7 @@
             try:
                 pdf_meta = {"/Title": wikiutil.escape(xmp_meta.dc_title['x-default']),
                             "/Author": wikiutil.escape(pdf_meta['/Author'])}
-            except AttributeError:
+            except AttributeError, KeyError:
                 pass
 
 
@@ -114,12 +114,22 @@
                                  fmt.url(0))
 
 
-            try:
-                html.append("%(/Author)s</td><td>%(/Title)s</td><td>" % {"/Title": wikiutil.escape(pdf_meta['/Title']),
-                                                                         "/Author": wikiutil.escape(pdf_meta['/Author'])})
-            except KeyError:
+            title = None
+            author = None
+            if pdf_meta.has_key('/Title'):
+                title = pdf_meta['/Title']
+            if pdf_meta.has_key('/Author'):
+                author = pdf_meta['/Author']
+
+
+            if author or title:
+                html.append("%(/Author)s</td><td>%(/Title)s</td><td>" % {"/Title": wikiutil.escape(title),
+                                                                         "/Author": wikiutil.escape(author)})
+
+            else:
                 html.append('</td><td>%(filename)s</td><td>' % {"filename": file})
 
+
             html.append("%s" % "&nbsp;</td><td> ".join(links))
             html.append('</td>')
             html.append('</tr>')