Mercurial > hg > documentViewer
changeset 454:73e3273c7624 elementtree
more work
author | casties |
---|---|
date | Fri, 15 Jul 2011 11:02:26 +0200 |
parents | beb7ccb92564 |
children | 0a53fea83df7 |
files | documentViewer.py |
diffstat | 1 files changed, 13 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/documentViewer.py Thu Jul 14 19:43:56 2011 +0200 +++ b/documentViewer.py Fri Jul 15 11:02:26 2011 +0200 @@ -499,8 +499,7 @@ docinfo = {} for x in range(cut): - - path=getParentDir(path) + path=getParentDir(path) infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path @@ -630,17 +629,17 @@ logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path)) # put in all raw bib fields as dict "bib" - bib = dom.find(".//bib/*") + bib = dom.find(".//bib") #bib = dom.xpath("//bib/*") - if bib and len(bib)>0: + if bib is not None: bibinfo = {} for e in bib: - bibinfo[e.localName] = getTextFromNode(e) + bibinfo[e.tag] = getText(e) + docinfo['bib'] = bibinfo # extract some fields (author, title, year) according to their mapping metaData=self.metadata.main.meta.bib - bib = dom.find(".//bib") bibtype=bib.get("type") #bibtype=dom.xpath("//bib/@type") if not bibtype: @@ -711,7 +710,8 @@ # docinfo['isbn_issn']='' return docinfo - + + # TODO: is this needed? def getNameFromIndexMeta(self,path,docinfo=None,dom=None,cut=0): """gets name info from the index.meta file at path or given by dom""" if docinfo is None: @@ -739,11 +739,11 @@ archivePath = None archiveName = None - archiveName = getTextFromNode(dom.find("name")) + archiveName = getText(dom.find("name")) if not archiveName: logging.warning("documentViewer (getdocinfofromtexttool) resource/name missing in: %s" % (url)) - archivePath = getTextFromNode(dom.find("archive-path")) + archivePath = getText(dom.find("archive-path")) if archivePath: # clean up archive path if archivePath[0] != '/': @@ -807,6 +807,7 @@ presentationUrl = getText(dom.find(".//texttool/presentation")) docinfo = self.getBibinfoFromIndexMeta(url, docinfo=docinfo, dom=dom) # get info von bib tag + # TODO: is this needed here? docinfo = self.getNameFromIndexMeta(url, docinfo=docinfo, dom=dom) @@ -830,18 +831,9 @@ """gets the bibliographical information from the preseantion entry in texttools """ dom=self.getPresentationInfoXML(url) - try: - docinfo['author']=getText(dom.find(".//author")) - except: - pass - try: - docinfo['title']=getText(dom.find(".//title")) - except: - pass - try: - docinfo['year']=getText(dom.find(".//date")) - except: - pass + docinfo['author']=getText(dom.find(".//author")) + docinfo['title']=getText(dom.find(".//title")) + docinfo['year']=getText(dom.find(".//date")) return docinfo def getDocinfoFromImagePath(self,path,docinfo=None,cut=0):