diff SrvTxtUtils.py @ 207:938add25f81b

export shortenString to web
author casties
date Mon, 01 Jul 2013 12:59:10 +0200
parents 16d55695f1c8
children 3b517b412f77
line wrap: on
line diff
--- a/SrvTxtUtils.py	Thu Jun 27 17:46:28 2013 +0200
+++ b/SrvTxtUtils.py	Mon Jul 01 12:59:10 2013 +0200
@@ -213,6 +213,9 @@
 
 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."""
+    if len(s) <= l:
+        return s
+    
     l1 = int((l - len(ellipsis)) / 2)
     return "%s%s%s"%(s[:l1],ellipsis,s[-l1:])