summaryrefslogtreecommitdiffstats
path: root/example1.py
blob: 4006eac71a07e0d11d69c49fb994c197d5a7d6fb (plain)
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
#!/usr/bin/env python
"""Simple example usage of terminaltables without any other dependencies.

Just prints sample text and exits.
"""


from terminaltables3 import AsciiTable, DoubleTable, SingleTable

TABLE_DATA = (
    ("Platform", "Years", "Notes"),
    ("Mk5", "2007-2009", "The Golf Mk5 Variant was\nintroduced in 2007."),
    ("MKVI", "2009-2013", "Might actually be Mk5."),
)


def main():
    """Main function."""
    title = "Jetta SportWagen"

    # AsciiTable.
    table_instance = AsciiTable(TABLE_DATA, title)
    table_instance.justify_columns[2] = "right"
    print(table_instance.table)
    print()

    # SingleTable.
    table_instance = SingleTable(TABLE_DATA, title)
    table_instance.justify_columns[2] = "right"
    print(table_instance.table)
    print()

    # DoubleTable.
    table_instance = DoubleTable(TABLE_DATA, title)
    table_instance.justify_columns[2] = "right"
    print(table_instance.table)
    print()


if __name__ == "__main__":
    main()