--- MPIWGWeb/Attic/MPIWGHelper.py 2008/08/27 12:12:48 1.1.2.4 +++ MPIWGWeb/Attic/MPIWGHelper.py 2008/08/28 18:20:09 1.1.2.6 @@ -23,8 +23,8 @@ def sortStopWordsF(self,xo,yo): if not hasattr(self,'_v_stopWords'): self._v_stopWords=self.stopwords_en.data.split("\n") - x=str(xo[1]) - y=str(yo[1]) + x=unicodify(xo[1]) + y=unicodify(yo[1]) strx=x.split(" ") stry=y.split(" ") @@ -77,7 +77,7 @@ def sortI(x,y): def unicodify(str): """decode str (utf-8 or latin-1 representation) into unicode object""" - logging.error("unicodify: %s"%str) + #logging.error("unicodify: %s"%str) if not str: return "" if type(str) is StringType: @@ -97,3 +97,8 @@ def utf8ify(str): else: return str.encode('utf-8') + +def shortenString(s, l, ellipsis='...'): + """returns a string of length l (or l-1) by omitting characters in the middle of s, replacing with ellipsis.""" + l1 = int((l - len(ellipsis)) / 2) + return "%s%s%s"%(s[:l1],ellipsis,s[-l1:])