--- MPIWGWeb/Attic/MPIWGHelper.py 2008/08/27 21:08:40 1.1.2.5 +++ MPIWGWeb/Attic/MPIWGHelper.py 2008/08/28 18:20:09 1.1.2.6 @@ -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:])