Changeset 462:0d378e8ebcc3 in documentViewer for documentViewer.py


Ignore:
Timestamp:
Jul 27, 2011, 7:09:44 PM (13 years ago)
Author:
casties
Branch:
elementtree
Message:

accomodate new MetaDataFolder?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • documentViewer.py

    r461 r462  
    582582       
    583583        logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path))
    584         # put all raw bib fields in dict "bib"
    585         bib = getBibdataFromDom(dom)
    586         docinfo['bib'] = bib
    587         bibtype = bib.get('@type', None)
    588         docinfo['bib_type'] = bibtype
    589         if bibtype:
    590             # also store standard mapped metadata for convenience
    591             try:
    592                 stdbib = self.metadata.getStdMappedHash(bib)
    593                 docinfo['std_bib'] = stdbib
    594                 docinfo['author'] = stdbib['author']
    595                 docinfo['title'] = stdbib['title']
    596                 docinfo['year'] = stdbib['year']
    597             except:
    598                 pass
    599 
     584        # try to get MetaDataFolder
     585        metadata = getattr(self, 'metadata')
     586        if metadata is not None:
     587            # put all raw bib fields in dict "bib"
     588            bib = metadata.getBibdataFromDom(dom)
     589            docinfo['bib'] = bib
     590            bibtype = bib.get('@type', None)
     591            docinfo['bib_type'] = bibtype
     592            # also store DC metadata for convenience
     593            dc = metadata.getDCMappedData(bib)
     594            docinfo['creator'] = dc.get('creator',None)
     595            docinfo['title'] = dc.get('title',None)
     596            docinfo['date'] = dc.get('date',None)
     597        else:
     598            logging.error("MetaDataFolder 'metadata' not found!")
     599            #TODO: remove
     600            bib = getBibdataFromDom(dom)
    600601        return docinfo
    601602   
Note: See TracChangeset for help on using the changeset viewer.