--- documentViewer/documentViewer.py 2011/07/20 19:36:57 1.175.2.7 +++ documentViewer/documentViewer.py 2011/07/26 18:09:26 1.175.2.8 @@ -102,9 +102,12 @@ def getParentDir(path): """returns pathname shortened by one""" return '/'.join(path.split('/')[0:-1]) -def normalizeBibtype(bt): +def normalizeBibField(bt, underscore=True): """returns normalised bib type for looking up mappings""" bt = bt.strip().replace(' ', '-').lower() + if underscore: + bt = bt.replace('_', '-') + return bt def getBibdataFromDom(dom): @@ -114,13 +117,14 @@ def getBibdataFromDom(dom): if bib is not None: # put type in @type type = bib.get('type') - bibinfo['@type'] = normalizeBibtype(type) + bibinfo['@type'] = normalizeBibField(type) # put all subelements in dict for e in bib: - bibinfo[e.tag] = getText(e) + bibinfo[normalizeBibField(e.tag)] = getText(e) return bibinfo + ## ## documentViewer class ##