Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions archinstall/lib/utils/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
23 changes: 0 additions & 23 deletions archinstall/lib/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from datetime import UTC, datetime

from archinstall.lib.pathnames import ARCHISO_MOUNTPOINT
from archinstall.lib.utils.format import as_columns


def timestamp() -> str:
Expand All @@ -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