Annotation of MPIWGWeb/MPIWGHelper.py, revision 1.1.2.3

1.1.2.2   dwinter     1: from types import *
                      2: 
1.1.2.1   dwinter     3: definedFields=['WEB_title','xdata_01','xdata_02','xdata_03','xdata_04','xdata_05','xdata_06','xdata_07','xdata_08','xdata_09','xdata_10','xdata_11','xdata_12','xdata_13','WEB_project_header','WEB_project_description','WEB_related_pub']
                      4: 
                      5: checkFields = ['xdata_01']
                      6: 
                      7: #ersetzt logging
                      8: def logger(txt,method,txt2):
                      9:     """logging""" 
                     10:     logging.info(txt+ txt2)
                     11:                  
                     12: def getTextFromNode(nodename):
                     13:     
                     14:     nodelist=nodename.childNodes
                     15:     rc = ""
                     16:     for node in nodelist:
                     17:         if node.nodeType == node.TEXT_NODE:
                     18:            rc = rc + node.data
                     19:     return rc
                     20: 
                     21: 
                     22: def sortStopWordsF(self,xo,yo):
                     23:     if not hasattr(self,'_v_stopWords'):
                     24:         self._v_stopWords=self.stopwords_en.data.split("\n")
                     25:     
                     26:     x=str(xo[1])
                     27:     y=str(yo[1])
                     28:     
                     29:     strx=x.split(" ")
                     30:     stry=y.split(" ")
                     31:     
                     32:     for tmp in strx:
                     33:         if tmp.lower() in self._v_stopWords:
                     34:             del strx[strx.index(tmp)]
                     35:     
                     36:     for tmp in stry:
                     37:         if tmp.lower() in self._v_stopWords:
                     38:             del stry[stry.index(tmp)]
                     39:             
                     40:     return cmp(" ".join(strx)," ".join(stry))
                     41:     
                     42: def sortStopWords(self):
                     43:     return lambda x,y : sortStopWordsF(self,x,y)
                     44:     
                     45: def sortF(x,y):
                     46:     try:
                     47:         return cmp(x[1],y[1])
                     48:     except:
                     49:         try:
                     50:             return cmp(str(x[1]),str(y[1]))
                     51:         except:           
                     52:             
                     53:             return 0 
                     54:     
                     55: def sortI(x,y):
                     56:     xsplit=x[1].split(".")
                     57:     ysplit=y[1].split(".")
                     58:     xret=""
                     59:     yret=""
                     60:     try:
                     61:         for i in range(5):
                     62:             try:
                     63:                 yret=yret+"%04i"%int(xsplit[i])
                     64:             except:
                     65:                 yret=yret+"%04i"%0
                     66: 
                     67:             try:
                     68:                 xret=xret+"%04i"%int(ysplit[i])
                     69:             except:
                     70:                 xret=xret+"%04i"%0
                     71:                 
                     72:         
                     73:         return cmp(int(yret),int(xret))
                     74:     except:
                     75:         return cmp(x[1],y[1])
                     76: 
                     77: 
                     78: def unicodify(str):
                     79:     """decode str (utf-8 or latin-1 representation) into unicode object"""
1.1.2.3 ! dwinter    80:     logging.error("unicodify: %s"%str)
1.1.2.1   dwinter    81:     if not str:
                     82:         return ""
                     83:     if type(str) is StringType:
                     84:         try:
                     85:             return str.decode('utf-8')
                     86:         except:
                     87:             return str.decode('latin-1')
                     88:     else:
                     89:         return str
                     90: 
                     91: def utf8ify(str):
                     92:     """encode unicode object or string into byte string in utf-8 representation"""
                     93:     if not str:
                     94:         return ""
                     95:     if type(str) is StringType:
                     96:         return str
                     97:     else:
                     98:         return str.encode('utf-8')
                     99: 

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