Strip whitespace from micropip.list() output (#2181)

This commit is contained in:
Gyeongjae Choi 2022-02-16 23:06:43 +09:00 committed by GitHub
parent 55fbd32ef3
commit fcc8c4889f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 5 deletions

View File

@ -7,21 +7,19 @@ __all__ = ["PackageDict"]
def _format_table(headers: List[str], table: List[Iterable]) -> str:
# fmt: off
"""
Returns a minimal formatted table
>>> print(_format_table(["Header1", "Header2"], [["val1", "val2"], ["val3", "val4"]]))
Header1 | Header2
------- | -------
val1 | val2
val3 | val4
val1 | val2
val3 | val4
"""
# fmt: on
def format_row(values, widths, filler=""):
row = " | ".join(f"{x:{filler}<{w}}" for x, w in zip(values, widths))
return row
return row.rstrip()
col_width = [max(len(x) for x in col) for col in zip(headers, *table)]
rows = []