* Add tests for app/print_table.py * Exclude app/version and app/args from coverage * Remove app/main from coverage (just uses other modules)
24 lines
660 B
Python
24 lines
660 B
Python
#!/usr/bin/env python3
|
|
|
|
"""MODULE: Provides functions for preparing, then printing, retrieved data."""
|
|
|
|
from typing import Union
|
|
from tabulate import tabulate
|
|
|
|
|
|
def generate_prefix_string(prefixes: list) -> Union[str, None]:
|
|
"""Generate a string that spilts prefixes into rows of 4."""
|
|
num_per_row = 4
|
|
try:
|
|
ret = ""
|
|
for i in range(0, len(prefixes), num_per_row):
|
|
ret += ", ".join(prefixes[i : i + num_per_row]) + "\n"
|
|
return ret
|
|
except AttributeError:
|
|
return None
|
|
|
|
|
|
def print_table(table_data) -> None: # pragma: no cover
|
|
"""Print table generated by tabulate."""
|
|
print(tabulate(table_data))
|