mirror of
https://github.com/kennethreitz/clint.git
synced 2026-06-05 23:00:18 +00:00
Added support for colored unicode
This commit is contained in:
@@ -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__
|
||||
|
||||
@@ -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))
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
python unicode.py こんにちは。
|
||||
Reference in New Issue
Block a user