Mercurial > hg > MPIWGWeb
comparison SrvTxtUtils.py @ 188:16d55695f1c8
fix updating staff entries through "Update personal homepages". (creating new entries doesn't work)
author | casties |
---|---|
date | Fri, 14 Jun 2013 17:36:09 +0200 |
parents | 485bf377913a |
children | 938add25f81b |
comparison
equal
deleted
inserted
replaced
187:71c2d76f09b5 | 188:16d55695f1c8 |
---|---|
8 import stat | 8 import stat |
9 import urllib | 9 import urllib |
10 import urllib2 | 10 import urllib2 |
11 import logging | 11 import logging |
12 import time | 12 import time |
13 import re | |
13 | 14 |
14 import xml.etree.ElementTree as ET | 15 import xml.etree.ElementTree as ET |
15 | 16 |
16 srvTxtUtilsVersion = "1.9.2" | 17 srvTxtUtilsVersion = "1.10.0" |
17 | 18 |
18 map_months = {'en': [u"", | 19 map_months = {'en': [u"", |
19 u"January", | 20 u"January", |
20 u"February", | 21 u"February", |
21 u"March", | 22 u"March", |
213 def shortenString(s, l, ellipsis='...'): | 214 def shortenString(s, l, ellipsis='...'): |
214 """returns a string of length l (or l-1) by omitting characters in the middle of s, replacing with ellipsis.""" | 215 """returns a string of length l (or l-1) by omitting characters in the middle of s, replacing with ellipsis.""" |
215 l1 = int((l - len(ellipsis)) / 2) | 216 l1 = int((l - len(ellipsis)) / 2) |
216 return "%s%s%s"%(s[:l1],ellipsis,s[-l1:]) | 217 return "%s%s%s"%(s[:l1],ellipsis,s[-l1:]) |
217 | 218 |
219 | |
220 def sqlName(s, lc=True, more=''): | |
221 """returns restricted ASCII-only version of string""" | |
222 if s is None: | |
223 return "" | |
224 | |
225 if not isinstance(s, basestring): | |
226 # make string object | |
227 s = str(s) | |
228 | |
229 # remove ' | |
230 s = s.replace("'","") | |
231 # all else -> "_" | |
232 s = re.sub('[^A-Za-z0-9_'+more+']','_',s) | |
233 if lc: | |
234 return s.lower() | |
235 | |
236 return s | |
237 | |
238 |