# HG changeset patch # User casties # Date 1311703766 -7200 # Node ID 8732f15df5f3d44230dbe9305f18669aeea8d529 # Parent 76bc2317146f4a932e259c1effaba57bb13b4d2e more renovation diff -r 76bc2317146f -r 8732f15df5f3 documentViewer.py --- a/documentViewer.py Wed Jul 20 21:36:57 2011 +0200 +++ b/documentViewer.py Tue Jul 26 20:09:26 2011 +0200 @@ -102,9 +102,12 @@ """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 @@ 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 ##