forked from Robpol86/terminaltables
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample2.py
executable file
·53 lines (41 loc) · 1.42 KB
/
example2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
"""Example usage of terminaltables using colorclass.
Just prints sample text and exits.
"""
from __future__ import print_function
from colorclass import Color, Windows
from terminaltables import SingleTable
Windows.enable(auto_colors=True, reset_atexit=True) # Does nothing if not on Windows.
table_data = [
[Color('{autogreen}<10ms{/autogreen}'), '192.168.0.100, 192.168.0.101'],
[Color('{autoyellow}10ms <= 100ms{/autoyellow}'), '192.168.0.102, 192.168.0.103'],
[Color('{autored}>100ms{/autored}'), '192.168.0.105'],
]
table = SingleTable(table_data)
table.inner_heading_row_border = False
print()
print(table.table)
table.title = '192.168.0.105'
table.justify_columns = {0: 'center', 1: 'center', 2: 'center'}
table.inner_row_border = True
table.table_data = [
[Color('Low Space'), Color('{autocyan}Nominal Space{/autocyan}'), Color('Excessive Space')],
[Color('Low Load'), Color('Nominal Load'), Color('{autored}High Load{/autored}')],
[Color('{autocyan}Low Free RAM{/autocyan}'), Color('Nominal Free RAM'), Color('High Free RAM')],
]
print()
print(table.table)
table.title = None
table.outer_border = False
table.table_data = [['A', 'B'], ['C', 'D']]
print()
print(table.table)
table.outer_border = True
table.inner_row_border = False
table.inner_column_border = False
print()
print(table.table)
table = SingleTable([['Obey Obey Obey Obey']], 'Instructions')
print()
print(table.table)
print()