diff SrvTxtUtils.py @ 65:63184d71c014

lots of cleaning up.
author casties
date Fri, 03 May 2013 18:23:01 +0200
parents e40ff9829108
children 77f2478ae971
line wrap: on
line diff
--- a/SrvTxtUtils.py	Fri May 03 12:00:34 2013 +0200
+++ b/SrvTxtUtils.py	Fri May 03 18:23:01 2013 +0200
@@ -9,10 +9,11 @@
 import urllib
 import urllib2
 import logging
+import time
 
 import xml.etree.ElementTree as ET
 
-srvTxtUtilsVersion = "1.7"
+srvTxtUtilsVersion = "1.8"
 
 map_months = {'en': [u"",
                u"January",
@@ -174,3 +175,9 @@
     # call original method
     return ImageFile.index_html(self, REQUEST, RESPONSE)
 
+
+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:])
+