forked from Robpol86/terminaltables
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample3.py
More file actions
executable file
·27 lines (19 loc) · 1020 Bytes
/
example3.py
File metadata and controls
executable file
·27 lines (19 loc) · 1020 Bytes
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
#!/usr/bin/env python
"""Simple example usage of terminaltables and column_max_width().
Just prints sample text and exits.
"""
from __future__ import print_function
from textwrap import wrap
from terminaltables import SingleTable
# Setup string and table.
long_string = ('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore '
'et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut '
'aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum '
'dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui '
'officia deserunt mollit anim id est laborum.')
table = SingleTable([['Long String', '']])
# Calculate newlines.
max_width = table.column_max_width(1)
wrapped_string = '\n'.join(wrap(long_string, max_width))
table.table_data[0][1] = wrapped_string
print(table.table)