summaryrefslogtreecommitdiff
path: root/odoo/tools
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2018-01-03 12:39:08 +0100
committerThibault Delavallée <tde@odoo.com>2018-01-11 11:52:37 +0100
commitcdfe479e2e92b8bfc4e4d5bb32c1db8ad5c431d6 (patch)
tree76b793c56dc98bed3c8fcafc7ecf1a9fa7daf036 /odoo/tools
parent782154da11975b9db4620d7d39df3b567f3abcdc (diff)
[MOV] mail: reorder a bit mail thread methods by category
As this class has grown a lot some methods have been put a bit anywhere in the file. To prepare future improvements it is easier to regroup them a bit. remove_accent from mail_alias is also moved to tools in order to separate tools from business or class specific code.
Diffstat (limited to 'odoo/tools')
-rw-r--r--odoo/tools/misc.py15
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.