changeset 462:0d378e8ebcc3 elementtree

accomodate new MetaDataFolder
author casties
date Wed, 27 Jul 2011 21:09:44 +0200
parents 8732f15df5f3
children 89ad327b4bbd
files documentViewer.py
diffstat 1 files changed, 17 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/documentViewer.py	Tue Jul 26 20:09:26 2011 +0200
+++ b/documentViewer.py	Wed Jul 27 21:09:44 2011 +0200
@@ -581,22 +581,23 @@
         docinfo['indexMetaPath']=self.getIndexMetaPath(path);
         
         logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path))
-        # put all raw bib fields in dict "bib"
-        bib = getBibdataFromDom(dom)
-        docinfo['bib'] = bib
-        bibtype = bib.get('@type', None)
-        docinfo['bib_type'] = bibtype
-        if bibtype:
-            # also store standard mapped metadata for convenience
-            try:
-                stdbib = self.metadata.getStdMappedHash(bib)
-                docinfo['std_bib'] = stdbib
-                docinfo['author'] = stdbib['author']
-                docinfo['title'] = stdbib['title']
-                docinfo['year'] = stdbib['year']
-            except:
-                pass
-
+        # try to get MetaDataFolder
+        metadata = getattr(self, 'metadata')
+        if metadata is not None:
+            # put all raw bib fields in dict "bib"
+            bib = metadata.getBibdataFromDom(dom)
+            docinfo['bib'] = bib
+            bibtype = bib.get('@type', None)
+            docinfo['bib_type'] = bibtype
+            # also store DC metadata for convenience
+            dc = metadata.getDCMappedData(bib)
+            docinfo['creator'] = dc.get('creator',None)
+            docinfo['title'] = dc.get('title',None)
+            docinfo['date'] = dc.get('date',None)
+        else:
+            logging.error("MetaDataFolder 'metadata' not found!")
+            #TODO: remove
+            bib = getBibdataFromDom(dom)
         return docinfo