def _fold_no_color(self, a, b): try: A = a.no_color() except AttributeError: A = unicode(a) try: B = b.no_color() except AttributeError: B = unicode(b) return smart_str(A) + smart_str(B)
def __str__(self): return smart_str(self.__unicode__())
def __unicode__(self): suffix = '' if self.enabled: suffix = RESET_SEQ return smart_str(self.embed() + suffix)
def embed(self): prefix = '' if self.enabled: prefix = self.op return prefix + smart_str(reduce(self._add, self.s))
def test_smart_str(self): self.assertEqual(self.bytes_str, smart_str(self.decoded_bytes_str)) self.assertIsInstance(smart_str(self.decoded_bytes_str), str) self.assertEqual(self.bytes_str, smart_str(self.bytes_str)) self.assertIsInstance(smart_str(self.bytes_str), str)