diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2013-03-01 18:28:38 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2013-03-01 18:28:38 +0400 |
commit | 462e4bee87f085ae775eaa953a832bfcf6503ca3 (patch) | |
tree | f19ca485887c7420d7eeced0dfc565c4340977bd /release/scripts/modules/bl_i18n_utils/utils.py | |
parent | 41935d10c9e20b2138c5560f6103f080df0c1e9f (diff) |
More tweaks (gaining about ten seconds for each po in update branches process!).
Diffstat (limited to 'release/scripts/modules/bl_i18n_utils/utils.py')
-rw-r--r-- | release/scripts/modules/bl_i18n_utils/utils.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py index 5bb0a072ccb..f9890d79144 100644 --- a/release/scripts/modules/bl_i18n_utils/utils.py +++ b/release/scripts/modules/bl_i18n_utils/utils.py @@ -29,6 +29,7 @@ import re import struct import sys import tempfile +#import time from bl_i18n_utils import settings, rtl_utils @@ -257,15 +258,23 @@ class I18nMessage: @classmethod def do_escape(cls, txt): """Replace some chars by their escaped versions!""" - txt = txt.replace("\n", "\\n").replace("\t", "\\t") - txt = cls._esc_quotes.sub(r'\1\"', txt) + if "\n" in txt: + txt = txt.replace("\n", r"\n") + if "\t" in txt: + txt.replace("\t", r"\t") + if '"' in txt: + txt = cls._esc_quotes.sub(r'\1\"', txt) return txt @classmethod def do_unescape(cls, txt): """Replace escaped chars by real ones!""" - txt = txt.replace("\\n", "\n").replace("\\t", "\t") - txt = cls._unesc_quotes.sub(r'\1"', txt) + if r"\n" in txt: + txt = txt.replace(r"\n", "\n") + if r"\t" in txt: + txt = txt.replace(r"\t", "\t") + if r'\"' in txt: + txt = cls._unesc_quotes.sub(r'\1"', txt) return txt def escape(self, do_all=False): @@ -277,8 +286,6 @@ class I18nMessage: names = self._esc_names_all if do_all else self._esc_names for name in names: setattr(self, name, [self.do_unescape(l) for l in getattr(self, name)]) - if None in getattr(self, name): - print(getattr(self, name)) class I18nMessages: |