本文整理汇总了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")