comparison MPIWGHelper.py @ 207:938add25f81b

export shortenString to web
author casties
date Mon, 01 Jul 2013 12:59:10 +0200
parents 90d44df497a6
children
comparison
equal deleted inserted replaced
206:31b28f369fd3 207:938add25f81b
89 unicodify = SrvTxtUtils.unicodify 89 unicodify = SrvTxtUtils.unicodify
90 90
91 # encode unicode object or string into byte string in utf-8 representation. 91 # encode unicode object or string into byte string in utf-8 representation.
92 utf8ify = SrvTxtUtils.utf8ify 92 utf8ify = SrvTxtUtils.utf8ify
93 93
94 def shortenString(s, l, ellipsis='...'): 94 # returns a string of length l (or l-1) by omitting characters in the middle of s, replacing with ellipsis.
95 """returns a string of length l (or l-1) by omitting characters in the middle of s, replacing with ellipsis.""" 95 shortenString = SrvTxtUtils.shortenString
96 l1 = int((l - len(ellipsis)) / 2)
97 return "%s%s%s"%(s[:l1],ellipsis,s[-l1:])
98 96
99 97
100 # 98 #
101 # navigation methods (should better be a mixin class) 99 # navigation methods (should better be a mixin class)
102 # 100 #