_misc
TOC
- Functions:
- 🅵 _create_table - Create a formatted table from the given header and contents.
- Classes:
- 🅲 CacheOut - A decorator class to cache the output of a method.
Functions
🅵 _create_table
_create_table
def _create_table(
header: str | list[str] | tuple[str, ...] | None,
contents: Sequence[str] | Sequence[Sequence[str]],
prefix: str = "\n",
**table_kwargs: Any
) -> str:
if len(contents) > 0 and isinstance(contents[0], str):
contents = [(i,) for i in contents]
if header is None:
header = ()
if not isinstance(header, (list, tuple)):
header = [header]
table = tabulate(
contents, headers=header, tablefmt="fancy_grid", **table_kwargs
)
return prefix + table