Example #1
0
 def _encode(self, text):
     raw = self._raw(text)
     if raw in self._cache or len(raw) < self._compress_threshold:
         return raw
     compressed = compress_text(text)
     if len(compressed) * self._use_compressed_threshold < len(raw):
         return compressed
     return raw
 def _encode(self, text):
     raw = self._raw(text)
     if raw in self._cache or len(raw) < self._compress_threshold:
         return raw
     compressed = compress_text(text)
     if len(compressed) * self._use_compressed_threshold < len(raw):
         return compressed
     return raw
Example #3
0
 def _encode(self, text, html=False):
     if html:
         text = html_format(text)
     if len(text) > self._compress_threshold:
         compressed = compress_text(text)
         if len(compressed) * self._use_compressed_threshold < len(text):
             return compressed
     # Strings starting with '*' are raw, others are compressed.
     return '*' + text
 def _compress(self, text):
     return utils.compress_text(text)