From: Antonio Ospite Date: Wed, 23 Dec 2015 18:26:51 +0000 (+0100) Subject: MorseTranslator.py: don't sanitize away word spaces X-Git-Url: https://git.ao2.it/SaveMySugar/python3-savemysugar.git/commitdiff_plain/551787e77bb5c57c84d88324131b26a4a5a8053c?hp=4b296ac4888d610aa49d62ee733389b83d2c9dc7 MorseTranslator.py: don't sanitize away word spaces Don't strip word spaces when sanitizing strings, those spaces may be part of the original message. --- diff --git a/src/savemysugar/MorseTranslator.py b/src/savemysugar/MorseTranslator.py index d52902d..068a0b9 100755 --- a/src/savemysugar/MorseTranslator.py +++ b/src/savemysugar/MorseTranslator.py @@ -140,8 +140,6 @@ class MorseTranslator(object): sanitized = text.lower() sanitized = re.sub(r"[^a-z0-9.,:?\'-/()\"=\+@ ]", "", sanitized) sanitized = re.sub(r"\s+", " ", sanitized) - sanitized = re.sub(r"^\s+", "", sanitized) - sanitized = re.sub(r"\s+$", "", sanitized) return sanitized def char_to_signal(self, character): @@ -163,8 +161,6 @@ class MorseTranslator(object): sanitized = re.sub(r"[^\-\.\/]", " ", sanitized) sanitized = re.sub(r"\s+", " ", sanitized) sanitized = re.sub(r"( ?/ ?)+", " / ", sanitized) - sanitized = re.sub(r"^[ /]+", "", sanitized) - sanitized = re.sub(r"[ /]+$", "", sanitized) return sanitized def signal_to_character(self, signal):