Added support for colored unicode

This commit is contained in:
Collin Watson
2012-01-14 00:59:44 -08:00
parent 73a9cd836b
commit ec46d65bd2
3 changed files with 39 additions and 1 deletions
+4 -1
View File
@@ -61,7 +61,10 @@ class ColoredString(object):
return "<%s-string: '%s'>" % (self.color, self.s)
def __unicode__(self):
return self.color_str
value = self.color_str
if isinstance(value, basestring):
return ('%s' % value).decode('utf8')
return value
if PY3:
__str__ = __unicode__
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
from clint import args
from clint.textui import colored, puts, indent
if __name__ == '__main__':
puts('Test:')
with indent(4):
puts('%s Fake test 1.' % colored.green(''))
puts('%s Fake test 2.' % colored.red(''))
puts('')
puts('Greet:')
with indent(4):
puts(colored.red('Здравствуйте'))
puts(colored.green('你好。'))
puts(colored.yellow('سلام'))
puts(colored.magenta('안녕하세요'))
puts(colored.blue('नमस्ते'))
puts(colored.cyan('γειά σου'))
puts('')
puts('Arguments:')
with indent(4):
for arg in args.all:
puts('%s' % colored.red(arg))
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
python unicode.py こんにちは。