--- documentViewer/documentViewer.py 2011/07/14 17:43:56 1.175.2.1 +++ documentViewer/documentViewer.py 2011/07/15 09:02:26 1.175.2.2 @@ -499,8 +499,7 @@ class documentViewer(Folder): 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 @@ class documentViewer(Folder): 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 @@ class documentViewer(Folder): # 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 @@ class documentViewer(Folder): 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 @@ class documentViewer(Folder): 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 @@ class documentViewer(Folder): """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):