--- a/src/pyams_utils/unicode.py Fri Jul 26 19:16:26 2019 +0200
+++ b/src/pyams_utils/unicode.py Tue Sep 17 11:28:42 2019 +0200
@@ -17,6 +17,8 @@
_unicodeTransTable = {}
+
+
def _fillUnicodeTransTable():
_corresp = [
("A", [0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x0100, 0x0102, 0x0104]),
@@ -69,9 +71,9 @@
for code in codes:
_unicodeTransTable[code] = char
+
_fillUnicodeTransTable()
-
removed_chars = '®©™…'
"""List of custom characters to remove from input strings"""
@@ -108,7 +110,8 @@
s = s.decode("utf-8", "replace")
s = s.translate(_unicodeTransTable)
if remove_punctuation:
- punctuation = ''.join(filter(lambda x: x not in keep_chars, string.punctuation + removed_chars))
+ punctuation = ''.join(filter(lambda x: x not in keep_chars,
+ string.punctuation + removed_chars))
s = ''.join(filter(lambda x: x not in punctuation, s))
if force_lower:
s = s.lower()
@@ -166,6 +169,7 @@
"""Get specified dict with values converted to unicode
:param dict value: input mapping of strings which may be converted to unicode
+ :param str encoding: output encoding
:return: dict; a new mapping with each value converted to unicode
>>> from pyams_utils.unicode import unidict
@@ -184,6 +188,7 @@
"""Get specified list with values converted to unicode
:param list value: input list of strings which may be converted to unicode
+ :param str encoding: output encoding
:return: list; a new list with each value converted to unicode
>>> from pyams_utils.unicode import unilist