changeset 461:8732f15df5f3 elementtree

more renovation
author casties
date Tue, 26 Jul 2011 20:09:26 +0200
parents 76bc2317146f
children 0d378e8ebcc3
files documentViewer.py
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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
 ##