File:  [Repository] / MPIWGWeb / bibliography.py
Revision 1.7.2.7: download - view: text, annotated - select for diffs - revision graph
Thu Sep 7 11:06:41 2006 UTC (17 years, 9 months ago) by dwinter
Branches: r2
new formatting for bibliography

    1: #TO DO author_semi_kolon etc. ersetzen durch Funktionen
    2: def formatBibliography(self,found):
    3:     ret=""
    4:     if found.id_institutsbibliographie and (not found.id_institutsbibliographie==''):
    5:         ret+=formatBiblHelp(self,found,table='institutsbiblio',id=found.id_institutsbibliographie)
    6:     else:
    7:         ret+=formatBiblHelp(self,found,table='bibliography',id=found.id_gen_bib)
    8:     return ret
    9: 
   10: def CRListToSemicolon(self,listStr,showall=False):
   11:     if listStr:
   12: 	listStr.replace(";","\n")
   13: 	list=listStr.split("\n")
   14: 	if not showall: #filter eigentuemer der hoempage
   15: 		for x in list:
   16: 
   17: 			if x==self.title: # loesche den Eigentuemer der Hoempage aus der Liste
   18: 				del(list[list.index(x)])
   19: 
   20: 	if len(list)==0: # kein anderer Autor
   21: 		return None
   22: 	elif showall:
   23: 		return "; ".join(list)
   24: 	else:
   25: 		return "(joint with %s)"%"; ".join(list)
   26:     else:
   27:         return None
   28:     
   29: def getBib(value):
   30:     if value:
   31:         return value
   32:     else:
   33:         return ""
   34: 
   35:     return ret
   36: def cleanPunctuation(teststr):
   37:     """clean up punktuation"""
   38:     ret=""
   39:     signs="!:;.,?"
   40:     for x in teststr:
   41:         if x in signs:
   42:                 if (len(ret)>0) and (ret[-1]==' '):
   43:                         ret=ret[0:-1]
   44:         ret+=x
   45:     return ret
   46: 
   47: def formatBiblHelp(self,found,table,id,foundIB=None):
   48:     ret=""
   49:     if not foundIB:
   50:         try:
   51:             foundIB=self.ZSQLInlineSearch(_table=table,id=id)[0]
   52: 
   53:         except:
   54:             return ret
   55:     
   56:     if foundIB.reference_type.lower()=='journal article':
   57: 	if CRListToSemicolon(foundIB.author):
   58: 	        ret+=getBib(CRListToSemicolon(foundIB.author))+". ""
   59: 	ret+=getBib(foundIB.title)+". &quot; "+"<i>%s</i>"%getBib(foundIB.secondary_title)+" "+getBib(foundIB.volume)+" ("
   60:         if not self.ZSQLisEmpty(foundIB.number):
   61:             ret+=foundIB.number+"&nbsp;"
   62: 
   63:         if foundIB.year:
   64:             ret+=getattr(foundIB,'year','')
   65:         ret+=")"
   66:         if foundIB.pages and (not foundIB.pages)=='':
   67:             ret+=": "+foundIB.pages+"."
   68: 
   69:     elif foundIB.reference_type.lower()=='edited book':
   70:         if CRListToSemicolon(self,foundIB.author):
   71:             ret+=CRListToSemicolon(self,foundIB.author)+" (Editor/s). &quot;" 
   72:         if foundIB.title and (not foundIB.title==""):
   73:             ret+="<i>"+foundIB.title+"</i>."
   74:         if foundIB.place_published and (not foundIB.place_published==''):
   75:             ret+=foundIB.place_published+": "
   76:         if foundIB.publisher and (not foundIB.publisher==''):
   77:             ret+=foundIB.publisher+", "
   78:         ret+=getBib(foundIB.year)+"."
   79: 
   80:     elif foundIB.reference_type.lower()=='book section' or foundIB.reference_type.lower()=='in book':
   81: 	if CRListToSemicolon(self,foundIB.author):
   82: 	        ret+=getBib(CRListToSemicolon(self,foundIB.author))+". &quot;"
   83: 	ret+=getBib(foundIB.title)+".&quot; In: <i>"+getBib(foundIB.secondary_title)+"</i>"
   84:         if (CRListToSemicolon(self,foundIB.secondary_author,showall=True)) and (not CRListToSemicolon(self,foundIB.secondary_author,showall=True)==''):
   85:             ret+=", eds.: "+CRListToSemicolon(self,foundIB.secondary_author,showall=True)
   86:         ret+=". "
   87:         if foundIB.pages and (not foundIB.pages)=='':
   88:             ret+=foundIB.pages+". "
   89:         if foundIB.place_published and (not foundIB.place_published==''):
   90:             ret+=foundIB.place_published+": "
   91:         if foundIB.publisher and (not foundIB.publisher==''):
   92:             ret+=foundIB.publisher+", "
   93:         ret+=getBib(foundIB.year)+"."
   94: 
   95:    
   96:     elif foundIB.reference_type.lower()=='book':
   97:         if CRListToSemicolon(self,foundIB.author):
   98: 	        ret+=getBib(CRListToSemicolon(self,foundIB.author))+". "
   99: 	ret+="<i>"+getBib(foundIB.title)+"</i>. "
  100:         if foundIB.pages and (not foundIB.pages==''):
  101:             ret+=foundIB.pages+". "
  102:         if foundIB.place_published and (not foundIB.place_published==''):
  103:             ret+=foundIB.place_published+": "
  104:         if foundIB.publisher and (not foundIB.publisher==''):
  105:             ret+=foundIB.publisher+", "
  106:         ret+=getBib(foundIB.year)+"."
  107: 
  108:     elif foundIB.reference_type.lower()=='newspaper article':
  109:         if CRListToSemicolon(self,foundIB.author):
  110: 	        ret+=CRListToSemicolon(self,foundIB.author)+". &quot;"
  111: 	ret+=foundIB.title+".&quot; <i>"+foundIB.secondary_title+"</i>, "
  112:         ret+=foundIB.date+"."+foundIB.year+","
  113:         if foundIB.pages and (not foundIB.pages==''):
  114:             ret+=foundIB.pages+". "
  115: 
  116: 
  117:             
  118:             
  119:     return cleanPunctuation(ret)

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>