Mercurial > hg > MPIWGWeb
diff 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 |
line wrap: on
line diff
--- a/SrvTxtUtils.py Fri Jun 14 15:49:53 2013 +0200 +++ b/SrvTxtUtils.py Fri Jun 14 17:36:09 2013 +0200 @@ -10,10 +10,11 @@ import urllib2 import logging import time +import re import xml.etree.ElementTree as ET -srvTxtUtilsVersion = "1.9.2" +srvTxtUtilsVersion = "1.10.0" map_months = {'en': [u"", u"January", @@ -215,3 +216,23 @@ l1 = int((l - len(ellipsis)) / 2) return "%s%s%s"%(s[:l1],ellipsis,s[-l1:]) + +def sqlName(s, lc=True, more=''): + """returns restricted ASCII-only version of string""" + if s is None: + return "" + + if not isinstance(s, basestring): + # make string object + s = str(s) + + # remove ' + s = s.replace("'","") + # all else -> "_" + s = re.sub('[^A-Za-z0-9_'+more+']','_',s) + if lc: + return s.lower() + + return s + +