-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathtable_consumer.py
43 lines (37 loc) · 1.26 KB
/
table_consumer.py
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
"""
The table consumer for 'sam list'
"""
from typing import Any, Dict
from samcli.commands._utils.table_print import pprint_column_names, pprint_columns
from samcli.lib.list.list_interfaces import ListInfoPullerConsumer
class StringConsumerTableOutput(ListInfoPullerConsumer):
"""
Outputs data in table format
"""
def consume(self, data: Dict[Any, Any]) -> None:
"""
Outputs the data in a table format
Parameters
----------
data: Dict[Any, Any]
The data to be outputted
"""
@pprint_column_names(
format_string=data["format_string"],
format_kwargs=data["format_args"],
table_header=data["table_name"],
)
def print_table_rows(**kwargs):
"""
Prints the rows of the table based on the data provided
"""
for entry in data["data"]:
pprint_columns(
columns=entry,
width=kwargs["width"],
margin=kwargs["margin"],
format_string=data["format_string"],
format_args=kwargs["format_args"],
columns_dict=data["format_args"].copy(),
)
print_table_rows()