Tabulate

Introduction

The Tabulate Extension includes the TabulateOutputHandler, and provides output handling based on the Tabulate library. Its format is familiar to users of MySQL, Postgres, etc.

Documentation References:

API References:

Requirements

  • Tabulate (pip install tabulate)

Configuration

This extension does not support any application level configuration settings or meta options.

Usage

Example: Using Tabulate Output Handler
cli
myapp.py
from cement import App
class MyApp(App):
class Meta:
label = 'myapp'
extensions = ['tabulate']
output_handler = 'tabulate'
with MyApp() as app:
app.run()
# create a dataset
headers = ['NAME', 'AGE', 'ADDRESS']
data = [
["Krystin Bartoletti", 47, "PSC 7591, Box 425, APO AP 68379"],
["Cris Hegan", 54, "322 Reubin Islands, Leylabury, NC 34388"],
["George Champlin", 25, "Unit 6559, Box 124, DPO AA 25518"],
]
app.render(data, headers=headers)
$ python myapp.py
| NAME | AGE | ADDRESS |
|--------------------+-----+-----------------------------------------|
| Krystin Bartoletti | 47 | PSC 7591, Box 425, APO AP 68379 |
| Cris Hegan | 54 | 322 Reubin Islands, Leylabury, NC 34388 |
| George Champlin | 25 | Unit 6559, Box 124, DPO AA 25518 |