From 5f2823948e4b8363074dae4b6ea8c587d71cbca1 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 27 Jul 2016 08:58:35 +0200 Subject: [PATCH] translation: tweak Translation.str/repr format - change output so it's unambiguous (None vs "None") - escape \n, \r, and \t (prevent line breaks in strokes.log entries) --- plover/translation.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plover/translation.py b/plover/translation.py index d5fa5cdf1..c1a525b2c 100644 --- a/plover/translation.py +++ b/plover/translation.py @@ -101,7 +101,12 @@ def __ne__(self, other): return not self.__eq__(other) def __str__(self): - return 'Translation(%s : %s)' % (self.rtfcre, self.english) + if self.english is None: + translation = 'None' + else: + translation = escape_translation(self.english) + translation = '"%s"' % translation.replace('"', r'\"') + return 'Translation(%s : %s)' % (self.rtfcre, translation) def __repr__(self): return str(self)