Remove unused format_cols (#4652)
This commit is contained in:
parent
b7ad6f7514
commit
6dff8525fd
|
|
@ -46,23 +46,6 @@ def as_key_value_pair(
|
|||
return table.stringify()
|
||||
|
||||
|
||||
def as_columns(entries: list[str], cols: int) -> str:
|
||||
"""
|
||||
Will format a list into a given number of columns
|
||||
"""
|
||||
chunks: list[list[str]] = []
|
||||
output = ''
|
||||
|
||||
for i in range(0, len(entries), cols):
|
||||
chunks.append(entries[i : i + cols])
|
||||
|
||||
for row in chunks:
|
||||
out_fmt = '{: <30} ' * len(row)
|
||||
output += out_fmt.format(*row) + '\n'
|
||||
|
||||
return output
|
||||
|
||||
|
||||
def _get_values(
|
||||
o: DataclassInstance,
|
||||
class_formatter: str | Callable | None = None, # type: ignore[type-arg] # pyright: ignore[reportMissingTypeArgument]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import string
|
|||
from datetime import UTC, datetime
|
||||
|
||||
from archinstall.lib.pathnames import ARCHISO_MOUNTPOINT
|
||||
from archinstall.lib.utils.format import as_columns
|
||||
|
||||
|
||||
def timestamp() -> str:
|
||||
|
|
@ -24,25 +23,3 @@ def running_from_iso() -> bool:
|
|||
def generate_password(length: int = 64) -> str:
|
||||
haystack = string.printable # digits, ascii_letters, punctuation (!"#$[] etc) and whitespace
|
||||
return ''.join(secrets.choice(haystack) for _ in range(length))
|
||||
|
||||
|
||||
def format_cols(items: list[str], header: str | None = None) -> str:
|
||||
if header:
|
||||
text = f'{header}:\n'
|
||||
else:
|
||||
text = ''
|
||||
|
||||
nr_items = len(items)
|
||||
if nr_items <= 4:
|
||||
col = 1
|
||||
elif nr_items <= 8:
|
||||
col = 2
|
||||
elif nr_items <= 12:
|
||||
col = 3
|
||||
else:
|
||||
col = 4
|
||||
|
||||
text += as_columns(items, col)
|
||||
# remove whitespaces on each row
|
||||
text = '\n'.join(t.strip() for t in text.split('\n'))
|
||||
return text
|
||||
|
|
|
|||
Loading…
Reference in New Issue