本文整理匯總了Python中Shine.CLI.TextTable.TextTable.color方法的典型用法代碼示例。如果您正苦於以下問題:Python TextTable.color方法的具體用法?Python TextTable.color怎麽用?Python TextTable.color使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Shine.CLI.TextTable.TextTable
的用法示例。
在下文中一共展示了TextTable.color方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_title_with_color
# 需要導入模塊: from Shine.CLI.TextTable import TextTable [as 別名]
# 或者: from Shine.CLI.TextTable.TextTable import color [as 別名]
def test_title_with_color(self):
"""display with title and color"""
tbl = TextTable("%filesystem %two")
tbl.title = "title"
tbl.color = True
tbl.append({'filesystem': 'foo', 'two': 'bar'})
self.assertEqual(str(tbl),
"====\033[34m title \033[0m===\n"
"\033[34mFILESYSTEM TWO\033[0m\n"
"---------- ---\n"
"foo bar")
示例2: setup_table
# 需要導入模塊: from Shine.CLI.TextTable import TextTable [as 別名]
# 或者: from Shine.CLI.TextTable.TextTable import color [as 別名]
def setup_table(options, fmt=None):
"""
Return a TextTable already setup based on display command line options like
color and header.
"""
tbl = TextTable(fmt)
tbl.color = (options.color == 'auto' and Globals()['color'] == 'auto' \
and sys.stdout.isatty()) or \
(options.color == 'auto' and Globals()['color'] == 'always') \
or (options.color == 'always')
tbl.show_header = options.header
return tbl
示例3: test_color
# 需要導入模塊: from Shine.CLI.TextTable import TextTable [as 別名]
# 或者: from Shine.CLI.TextTable.TextTable import color [as 別名]
def test_color(self):
"""display with color"""
tbl = TextTable("%one")
tbl.color = True
tbl.append({'one': 'foo'})
self.assertEqual(str(tbl), "\033[34mONE\033[0m\n---\nfoo")