當前位置: 首頁>>代碼示例>>Python>>正文


Python TextTable.TextTable類代碼示例

本文整理匯總了Python中Shine.CLI.TextTable.TextTable的典型用法代碼示例。如果您正苦於以下問題:Python TextTable類的具體用法?Python TextTable怎麽用?Python TextTable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TextTable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_pattern_fields

    def test_pattern_fields(self):
        """fields could be extracted from pattern"""
        tbl = TextTable("%foo %bar")
        self.assertEqual(['foo', 'bar'], tbl.pattern_fields())

        tbl = TextTable("%foo likes %>20bar and %other")
        self.assertEqual(['foo', 'bar', 'other'], tbl.pattern_fields())
開發者ID:kcgthb,項目名稱:lustre-shine,代碼行數:7,代碼來源:TextTableTest.py

示例2: test_several_lines

 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")
開發者ID:kcgthb,項目名稱:lustre-shine,代碼行數:7,代碼來源:TextTableTest.py

示例3: test_long_title_truncated

 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)
開發者ID:kcgthb,項目名稱:lustre-shine,代碼行數:10,代碼來源:TextTableTest.py

示例4: test_column_width_values

    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""")
開發者ID:kcgthb,項目名稱:lustre-shine,代碼行數:10,代碼來源:TextTableTest.py

示例5: test_title_with_color

    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")
開發者ID:kcgthb,項目名稱:lustre-shine,代碼行數:11,代碼來源:TextTableTest.py

示例6: test_sorting

    def test_sorting(self):
        """fill with 2 different sortings"""
        tbl = TextTable(fmt="%4fsname %node")
        tbl.show_header = False
        key = lambda t: t.TYPE
        table_fill(tbl, self._fs, key)
        self.assertEqual(str(tbl), 'c... foo2\nc... foo1\nc... foo3\nc... foo0')

        tbl = TextTable(fmt="%4fsname %node")
        tbl.show_header = False
        key = lambda t: t.DISPLAY_ORDER
        table_fill(tbl, self._fs, key)
        self.assertEqual(str(tbl), 'c... foo0\nc... foo1\nc... foo2\nc... foo3')
開發者ID:kcgthb,項目名稱:lustre-shine,代碼行數:13,代碼來源:DisplayTest.py

示例7: setup_table

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
開發者ID:kcgthb,項目名稱:lustre-shine,代碼行數:13,代碼來源:Display.py

示例8: test_two_fields

 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")
開發者ID:kcgthb,項目名稱:lustre-shine,代碼行數:5,代碼來源:TextTableTest.py

示例9: test_length

 def test_length(self):
     """table length"""
     tbl = TextTable()
     tbl.append({'one': 'foo1'})
     tbl.append({'one': 'foo3'})
     self.assertEqual(len(tbl), 2)
開發者ID:kcgthb,項目名稱:lustre-shine,代碼行數:6,代碼來源:TextTableTest.py

示例10: _fmt_str

 def _fmt_str(self, fmt, txt):
     tbl = TextTable(fmt)
     tbl.show_header = False
     table_fill(tbl, self._fs)
     self.assertEqual(str(tbl), txt)
開發者ID:kcgthb,項目名稱:lustre-shine,代碼行數:5,代碼來源:DisplayTest.py

示例11: test_simple

 def test_simple(self):
     """simple row"""
     tbl = TextTable("%one")
     tbl.append({'one': 'foo'})
     self.assertEqual(str(tbl), "ONE\n---\nfoo")
開發者ID:kcgthb,項目名稱:lustre-shine,代碼行數:5,代碼來源:TextTableTest.py

示例12: test_support

 def test_support(self):
     """fill with a support filter"""
     tbl = TextTable(fmt="%3type %node %count")
     tbl.show_header = False
     table_fill(tbl, self._fs, None, supports='dev')
     self.assertEqual(str(tbl), 'MGT foo1 1\nMDT foo2 1\nOST foo3 2')
開發者ID:kcgthb,項目名稱:lustre-shine,代碼行數:6,代碼來源:DisplayTest.py

示例13: test_header_label

 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")
開發者ID:kcgthb,項目名稱:lustre-shine,代碼行數:6,代碼來源:TextTableTest.py

示例14: test_column_alignement_header

 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")
開發者ID:kcgthb,項目名稱:lustre-shine,代碼行數:6,代碼來源:TextTableTest.py

示例15: test_title

 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")
開發者ID:kcgthb,項目名稱:lustre-shine,代碼行數:6,代碼來源:TextTableTest.py


注:本文中的Shine.CLI.TextTable.TextTable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。