def _parseString(self, txt):
import re, unicodedata, locale
if type(txt) is not str:
txt = txt.decode('utf-8')
locale.setlocale(locale.LC_ALL, 'ca_ES')
prog = re.compile("[-_àèìòùáéíóúñçÀÈÌÒÙÁÉÍÓÚÑÇ .a-zA-Z0-9]+$", re.L)
if not prog.match(txt):
return False
else:
# ~ Replace accents
txt = ''.join((c for c in unicodedata.normalize('NFD', txt) if unicodedata.category(c) != 'Mn'))
return txt.replace(" ", "_")
评论列表
文章目录