diff options
Diffstat (limited to 'odoo/tools/misc.py')
| -rw-r--r-- | odoo/tools/misc.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/odoo/tools/misc.py b/odoo/tools/misc.py index 77eca2873f1..ac3a56b3825 100644 --- a/odoo/tools/misc.py +++ b/odoo/tools/misc.py @@ -22,8 +22,10 @@ import sys import threading import time import types +import unicodedata import werkzeug.utils import zipfile + from collections import defaultdict, Iterable, Mapping, MutableSet, OrderedDict from itertools import islice, groupby, repeat from lxml import etree @@ -732,6 +734,19 @@ def attrgetter(*items): return tuple(resolve_attr(obj, attr) for attr in items) return g +# --------------------------------------------- +# String management +# --------------------------------------------- + +# Inspired by http://stackoverflow.com/questions/517923 +def remove_accents(input_str): + """Suboptimal-but-better-than-nothing way to replace accented + latin letters by an ASCII equivalent. Will obviously change the + meaning of input_str and work only for some cases""" + input_str = ustr(input_str) + nkfd_form = unicodedata.normalize('NFKD', input_str) + return u''.join([c for c in nkfd_form if not unicodedata.combining(c)]) + class unquote(str): """A subclass of str that implements repr() without enclosing quotation marks or escaping, keeping the original string untouched. The name come from Lisp's unquote. |
