# HG changeset patch # User Thierry Florac # Date 1568712522 -7200 # Node ID 49d63e4bf171be3d7e0f2b69428eaa8f303e065e # Parent 7ac9f0a4d2d03835e7a74dac60f29a2c5dced7e9 Formatting diff -r 7ac9f0a4d2d0 -r 49d63e4bf171 src/pyams_utils/unicode.py --- 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