Mercurial > hg > documentViewer
changeset 59:996b61d71351
added all fields from bib tag to docinfo
author | casties |
---|---|
date | Fri, 08 Jun 2007 20:10:22 +0200 |
parents | cc1d3d22ca72 |
children | 346e94770901 |
files | documentViewer.py |
diffstat | 1 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/documentViewer.py Fri May 04 15:17:02 2007 +0200 +++ b/documentViewer.py Fri Jun 08 20:10:22 2007 +0200 @@ -309,7 +309,7 @@ def getBibinfoFromIndexMeta(self,path,docinfo=None,dom=None): """gets bibliographical info from the index.meta file at path or given by dom""" - logger("documentViewer (getbibinfofromindexmeta)", logging.INFO,"path: %s"%(path)) + logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path)) if docinfo is None: docinfo = {} @@ -317,26 +317,36 @@ if dom is None: dom = self.getIndexMeta(getParentDir(path)) + # put in all raw bib fields as dict "bib" + bib = dom.xpath("//bib/*") + if bib and len(bib)>0: + bibinfo = {} + for e in bib: + bibinfo[e.localName] = getTextFromNode(e) + docinfo['bib'] = bibinfo + + # extract some fields (author, title, year) according to their mapping metaData=self.metadata.main.meta.bib bibtype=dom.xpath("//bib/@type") if bibtype and (len(bibtype)>0): bibtype=bibtype[0].value else: bibtype="generic" + bibtype=bibtype.replace("-"," ") # wrong typesiin index meta "-" instead of " " (not wrong! ROC) + docinfo['bib_type'] = bibtype bibmap=metaData.generateMappingForType(bibtype) - #print "bibmap: ", bibmap, " for: ", bibtype # if there is no mapping bibmap is empty (mapping sometimes has empty fields) if len(bibmap) > 0 and len(bibmap['author'][0]) > 0: docinfo['author']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['author'][0])[0]) docinfo['title']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['title'][0])[0]) docinfo['year']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['year'][0])[0]) - - logging.info("bla") + logging.debug("documentViewer (getbibinfofromindexmeta) using mapping for %s"%bibtype) try: docinfo['lang']=getTextFromNode(dom.xpath("//bib/lang")[0]) except: docinfo['lang']='' + return docinfo