MCPcopy Create free account
hub / github.com/archlinux/archinstall / as_key_value_pair

Function as_key_value_pair

archinstall/lib/utils/format.py:12–38  ·  view source on GitHub ↗

Formats key-values as a Rich Table: key1 : value1 key2 : value2 ...

(
	entries: dict[str, str | list[str] | bool],
	ignore_empty: bool = True,
)

Source from the content-addressed store, hash-verified

10
11
12def as_key_value_pair(
13 entries: dict[str, str | list[str] | bool],
14 ignore_empty: bool = True,
15) -> str:
16 """
17 Formats key-values as a Rich Table:
18 key1 : value1
19 key2 : value2
20 ...
21 """
22 table = BaseRichTable()
23 table.add_column('key', style='bold', no_wrap=True)
24 table.add_column('value', style='white', max_width=70)
25
26 for label, value in entries.items():
27 if ignore_empty and not value:
28 continue
29
30 if isinstance(value, bool):
31 value = 'Yes' if value else 'No'
32
33 if isinstance(value, list):
34 value = '\n '.join(str(val) for val in value)
35
36 table.add_row(label.title(), f': {value}')
37
38 return table.stringify()
39
40
41def as_columns(entries: list[str], cols: int) -> str:

Callers 1

as_summaryMethod · 0.90

Calls 3

stringifyMethod · 0.95
BaseRichTableClass · 0.90
itemsMethod · 0.45

Tested by

no test coverage detected