version 1.26, 2007/05/04 13:17:02
|
version 1.27, 2007/06/08 18:10:22
|
Line 309 class documentViewer(Folder):
|
Line 309 class documentViewer(Folder):
|
|
|
def getBibinfoFromIndexMeta(self,path,docinfo=None,dom=None): |
def getBibinfoFromIndexMeta(self,path,docinfo=None,dom=None): |
"""gets bibliographical info from the index.meta file at path or given by dom""" |
"""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: |
if docinfo is None: |
docinfo = {} |
docinfo = {} |
Line 317 class documentViewer(Folder):
|
Line 317 class documentViewer(Folder):
|
if dom is None: |
if dom is None: |
dom = self.getIndexMeta(getParentDir(path)) |
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 |
metaData=self.metadata.main.meta.bib |
bibtype=dom.xpath("//bib/@type") |
bibtype=dom.xpath("//bib/@type") |
if bibtype and (len(bibtype)>0): |
if bibtype and (len(bibtype)>0): |
bibtype=bibtype[0].value |
bibtype=bibtype[0].value |
else: |
else: |
bibtype="generic" |
bibtype="generic" |
|
|
bibtype=bibtype.replace("-"," ") # wrong typesiin index meta "-" instead of " " (not wrong! ROC) |
bibtype=bibtype.replace("-"," ") # wrong typesiin index meta "-" instead of " " (not wrong! ROC) |
|
docinfo['bib_type'] = bibtype |
bibmap=metaData.generateMappingForType(bibtype) |
bibmap=metaData.generateMappingForType(bibtype) |
#print "bibmap: ", bibmap, " for: ", bibtype |
|
# if there is no mapping bibmap is empty (mapping sometimes has empty fields) |
# if there is no mapping bibmap is empty (mapping sometimes has empty fields) |
if len(bibmap) > 0 and len(bibmap['author'][0]) > 0: |
if len(bibmap) > 0 and len(bibmap['author'][0]) > 0: |
docinfo['author']=getTextFromNode(dom.xpath("//bib/%s"%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['title']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['title'][0])[0]) |
docinfo['year']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['year'][0])[0]) |
docinfo['year']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['year'][0])[0]) |
|
logging.debug("documentViewer (getbibinfofromindexmeta) using mapping for %s"%bibtype) |
logging.info("bla") |
|
try: |
try: |
docinfo['lang']=getTextFromNode(dom.xpath("//bib/lang")[0]) |
docinfo['lang']=getTextFromNode(dom.xpath("//bib/lang")[0]) |
except: |
except: |
docinfo['lang']='' |
docinfo['lang']='' |
|
|
return docinfo |
return docinfo |
|
|
|
|