/usr/share/doc/python-cement-doc/html/_sources/examples/tabularized_output.txt is in python-cement-doc 2.10.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | Tabularized Output
==================
Users familiar with MySQL, PGSQL, etc find comfort in table-based output
patterns. For one it adds structure, and two generally makes things much
more readable. The folloiwing is an example of a simple app using the
:ref:`Tabulate <cement.ext.ext_tabulate>` extension:
.. code-block:: python
from cement.core.foundation import CementApp
from cement.core.controller import expose, CementBaseController
class MyController(CementBaseController):
class Meta:
label = 'base'
@expose(hide=True)
def default(self):
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"],
]
self.app.render(data, headers=headers)
class MyApp(CementApp):
class Meta:
label = 'myapp'
extensions = ['tabulate']
output_handler = 'tabulate'
handlers = [MyController]
with MyApp() as app:
app.run()
The output looks like:
.. code-block:: console
$ 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 |
|