blob: 0297ae87c8ce01fad684be281a1cd5f2bd885ecc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
"""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)
|