本文整理汇总了Python中Shine.CLI.TextTable.TextTable.append方法的典型用法代码示例。如果您正苦于以下问题:Python TextTable.append方法的具体用法?Python TextTable.append怎么用?Python TextTable.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shine.CLI.TextTable.TextTable
的用法示例。
在下文中一共展示了TextTable.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_several_lines
# 需要导入模块: from Shine.CLI.TextTable import TextTable [as 别名]
# 或者: from Shine.CLI.TextTable.TextTable import append [as 别名]
def test_several_lines(self):
"""list of rows"""
tbl = TextTable("%one")
tbl.append({'one': 'foo1'})
tbl.append({'one': 'foo2'})
tbl.append({'one': 'foo3'})
self.assertEqual(str(tbl), "ONE\n---\nfoo1\nfoo2\nfoo3")
示例2: test_column_width_values
# 需要导入模块: from Shine.CLI.TextTable import TextTable [as 别名]
# 或者: from Shine.CLI.TextTable.TextTable import append [as 别名]
def test_column_width_values(self):
"""column width with longer values"""
tbl = TextTable("%one %two")
tbl.append({'one': 'foo1', 'two': 'bar1'})
tbl.append({'one': 'foofoo2', 'two': 'barbar2'})
self.assertEqual(str(tbl),
"""ONE TWO
--- ---
foo1 bar1
foofoo2 barbar2""")
示例3: test_long_title_truncated
# 需要导入模块: from Shine.CLI.TextTable import TextTable [as 别名]
# 或者: from Shine.CLI.TextTable.TextTable import append [as 别名]
def test_long_title_truncated(self):
"""very wide data does not imply wery wide title"""
tbl = TextTable("%one %two")
tbl.title = "title"
tbl.append({'one': 'foobar', 'two': ' go' * 100})
self.assertEqual(str(tbl),
"== title =\n"
"ONE TWO\n"
"--- ---\n"
"foobar " + ' go' * 100)
示例4: test_title_with_color
# 需要导入模块: from Shine.CLI.TextTable import TextTable [as 别名]
# 或者: from Shine.CLI.TextTable.TextTable import append [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")
示例5: test_optional_column_non_empty
# 需要导入模块: from Shine.CLI.TextTable import TextTable [as 别名]
# 或者: from Shine.CLI.TextTable.TextTable import append [as 别名]
def test_optional_column_non_empty(self):
"""an non-empty optional column shoud be displayed"""
tbl = TextTable("%foo %bar")
tbl.optional_cols = [ 'bar' ]
tbl.append({'foo': 'zap', 'bar': 'zop' })
self.assertEqual(str(tbl), """FOO BAR\n--- ---\nzap zop""")
示例6: test_header_label
# 需要导入模块: from Shine.CLI.TextTable import TextTable [as 别名]
# 或者: from Shine.CLI.TextTable.TextTable import append [as 别名]
def test_header_label(self):
"""output with header label"""
tbl = TextTable("%fsname")
tbl.header_labels = {'fsname': 'filesystem'}
tbl.append({'fsname': 'foo'})
self.assertEqual(str(tbl), "FILESYSTEM\n----------\nfoo")
示例7: test_noheader
# 需要导入模块: from Shine.CLI.TextTable import TextTable [as 别名]
# 或者: from Shine.CLI.TextTable.TextTable import append [as 别名]
def test_noheader(self):
"""output without header"""
tbl = TextTable("%one")
tbl.show_header = False
tbl.append({'one': 'foo'})
self.assertEqual(str(tbl), "foo")
示例8: test_aliases
# 需要导入模块: from Shine.CLI.TextTable import TextTable [as 别名]
# 或者: from Shine.CLI.TextTable.TextTable import append [as 别名]
def test_aliases(self):
"""format with label aliases"""
tbl = TextTable("%o %t")
tbl.aliases = {'o': 'one', 't':'two'}
tbl.append({'one': 'foo1', 'two': 'bar1'})
self.assertEqual(str(tbl),"ONE TWO\n--- ---\nfoo1 bar1")
示例9: test_two_fields
# 需要导入模块: from Shine.CLI.TextTable import TextTable [as 别名]
# 或者: from Shine.CLI.TextTable.TextTable import append [as 别名]
def test_two_fields(self):
"""format with 2 fields"""
tbl = TextTable("%one %two")
tbl.append({'one': 'foo1', 'two':'bar1'})
self.assertEqual(str(tbl),"ONE TWO\n--- ---\nfoo1 bar1")
示例10: test_length
# 需要导入模块: from Shine.CLI.TextTable import TextTable [as 别名]
# 或者: from Shine.CLI.TextTable.TextTable import append [as 别名]
def test_length(self):
"""table length"""
tbl = TextTable()
tbl.append({'one': 'foo1'})
tbl.append({'one': 'foo3'})
self.assertEqual(len(tbl), 2)
示例11: test_special_character
# 需要导入模块: from Shine.CLI.TextTable import TextTable [as 别名]
# 或者: from Shine.CLI.TextTable.TextTable import append [as 别名]
def test_special_character(self):
"""espace character for %"""
tbl = TextTable("%one %%")
tbl.append({'one': '34'})
self.assertEqual(str(tbl), 'ONE %\n--- -\n34 %')
示例12: test_unknown_key
# 需要导入模块: from Shine.CLI.TextTable import TextTable [as 别名]
# 或者: from Shine.CLI.TextTable.TextTable import append [as 别名]
def test_unknown_key(self):
"""unknown key should raise KeyError"""
tbl = TextTable("%one is %nice")
tbl.append({'one': 'bar'})
self.assertRaises(KeyError, str, tbl)
示例13: test_column_alignement_header
# 需要导入模块: from Shine.CLI.TextTable import TextTable [as 别名]
# 或者: from Shine.CLI.TextTable.TextTable import append [as 别名]
def test_column_alignement_header(self):
"""column alignment with longer header"""
tbl = TextTable("%filesystem %two")
tbl.append({'filesystem': 'foo', 'two': 'bar'})
self.assertEqual(str(tbl),
"FILESYSTEM TWO\n---------- ---\nfoo bar")
示例14: test_optional_column_empty
# 需要导入模块: from Shine.CLI.TextTable import TextTable [as 别名]
# 或者: from Shine.CLI.TextTable.TextTable import append [as 别名]
def test_optional_column_empty(self):
"""an empty optional column should not be displayed"""
tbl = TextTable("%foo %bar")
tbl.optional_cols = [ 'bar' ]
tbl.append({'foo': 'zap', 'bar': None })
self.assertEqual(str(tbl), """FOO\n---\nzap""")
示例15: test_title
# 需要导入模块: from Shine.CLI.TextTable import TextTable [as 别名]
# 或者: from Shine.CLI.TextTable.TextTable import append [as 别名]
def test_title(self):
"""display with a simple title"""
tbl = TextTable("%one")
tbl.title = "test title"
tbl.append({'one': 'foo'})
self.assertEqual(str(tbl), "= test title =\nONE\n---\nfoo")