Changeset 59:996b61d71351 in documentViewer


Ignore:
Timestamp:
Jun 8, 2007, 6:10:22 PM (17 years ago)
Author:
casties
Branch:
default
Message:

added all fields from bib tag to docinfo

File:
1 edited

Legend:

Unmodified
Added
Removed
  • documentViewer.py

    r57 r59  
    310310    def getBibinfoFromIndexMeta(self,path,docinfo=None,dom=None):
    311311        """gets bibliographical info from the index.meta file at path or given by dom"""
    312         logger("documentViewer (getbibinfofromindexmeta)", logging.INFO,"path: %s"%(path))
     312        logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path))
    313313       
    314314        if docinfo is None:
     
    318318            dom = self.getIndexMeta(getParentDir(path))
    319319           
     320        # put in all raw bib fields as dict "bib"
     321        bib = dom.xpath("//bib/*")
     322        if bib and len(bib)>0:
     323            bibinfo = {}
     324            for e in bib:
     325                bibinfo[e.localName] = getTextFromNode(e)
     326            docinfo['bib'] = bibinfo
     327       
     328        # extract some fields (author, title, year) according to their mapping
    320329        metaData=self.metadata.main.meta.bib
    321330        bibtype=dom.xpath("//bib/@type")
     
    324333        else:
    325334            bibtype="generic"
     335           
    326336        bibtype=bibtype.replace("-"," ") # wrong typesiin index meta "-" instead of " " (not wrong! ROC)
     337        docinfo['bib_type'] = bibtype
    327338        bibmap=metaData.generateMappingForType(bibtype)
    328         #print "bibmap: ", bibmap, " for: ", bibtype
    329339        # if there is no mapping bibmap is empty (mapping sometimes has empty fields)
    330340        if len(bibmap) > 0 and len(bibmap['author'][0]) > 0:
     
    332342            docinfo['title']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['title'][0])[0])
    333343            docinfo['year']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['year'][0])[0])
    334            
    335             logging.info("bla")
     344            logging.debug("documentViewer (getbibinfofromindexmeta) using mapping for %s"%bibtype)
    336345            try:
    337346                docinfo['lang']=getTextFromNode(dom.xpath("//bib/lang")[0])
    338347            except:
    339348                docinfo['lang']=''
     349
    340350        return docinfo
    341351
Note: See TracChangeset for help on using the changeset viewer.