예제 #1
0
    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
0
    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")
예제 #3
0
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
예제 #4
0
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
예제 #5
0
 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")
예제 #6
0
 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")