comparison documentViewer.py @ 62:8a16ea8db858

fixed bug in getInt
author casties
date Fri, 15 Jun 2007 16:16:27 +0200
parents f3d2f240692c
children 4a17b755bfc7
comparison
equal deleted inserted replaced
61:f3d2f240692c 62:8a16ea8db858
30 def getInt(number, default=0): 30 def getInt(number, default=0):
31 """returns always an int (0 in case of problems)""" 31 """returns always an int (0 in case of problems)"""
32 try: 32 try:
33 return int(number) 33 return int(number)
34 except: 34 except:
35 return default 35 return int(default)
36 36
37 def getTextFromNode(nodename): 37 def getTextFromNode(nodename):
38 """get the cdata content of a node""" 38 """get the cdata content of a node"""
39 if nodename is None: 39 if nodename is None:
40 return "" 40 return ""
437 437
438 def getBibinfoFromTextToolPresentation(self,url,docinfo=None,dom=None): 438 def getBibinfoFromTextToolPresentation(self,url,docinfo=None,dom=None):
439 """gets the bibliographical information from the preseantion entry in texttools 439 """gets the bibliographical information from the preseantion entry in texttools
440 """ 440 """
441 dom=self.getPresentationInfoXML(url) 441 dom=self.getPresentationInfoXML(url)
442 docinfo['author']=getTextFromNode(dom.xpath("//author")[0]) 442 try:
443 docinfo['title']=getTextFromNode(dom.xpath("//title")[0]) 443 docinfo['author']=getTextFromNode(dom.xpath("//author")[0])
444 #docinfo['year']=getTextFromNode(dom.xpath("//date")[0]) 444 except:
445 pass
446 try:
447 docinfo['title']=getTextFromNode(dom.xpath("//title")[0])
448 except:
449 pass
450 try:
451 docinfo['year']=getTextFromNode(dom.xpath("//date")[0])
452 except:
453 pass
445 return docinfo 454 return docinfo
446 455
447 def getDocinfoFromImagePath(self,path,docinfo=None): 456 def getDocinfoFromImagePath(self,path,docinfo=None):
448 """path ist the path to the images it assumes that the index.meta file is one level higher.""" 457 """path ist the path to the images it assumes that the index.meta file is one level higher."""
449 logger("documentViewer (getdocinfofromimagepath)", logging.INFO,"path: %s"%(path)) 458 logger("documentViewer (getdocinfofromimagepath)", logging.INFO,"path: %s"%(path))