mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 23:10:17 +00:00
21 lines
611 B
Python
21 lines
611 B
Python
"""Tablib - Command-line Interface table export support.
|
|
|
|
Generates a representation for CLI from the dataset.
|
|
Wrapper for tabulate library.
|
|
"""
|
|
from tabulate import tabulate as Tabulate
|
|
|
|
|
|
class CLIFormat:
|
|
""" Class responsible to export to CLI Format """
|
|
title = 'cli'
|
|
DEFAULT_FMT = 'plain'
|
|
|
|
@classmethod
|
|
def export_set(cls, dataset, **kwargs):
|
|
"""Returns CLI representation of a Dataset."""
|
|
if dataset.headers:
|
|
kwargs.setdefault('headers', dataset.headers)
|
|
kwargs.setdefault('tablefmt', cls.DEFAULT_FMT)
|
|
return Tabulate(dataset, **kwargs)
|