summaryrefslogtreecommitdiff
path: root/python/vyos/utils/io.py
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-11-15 11:56:52 -0600
committerJohn Estabrook <jestabro@vyos.io>2023-11-16 12:53:43 -0600
commite036f783bc85e4d2bad5f5cbfd688a03a352223e (patch)
treed42d41c045c23ee7cd3a88307f4a5565227338a2 /python/vyos/utils/io.py
parentbd701768796d6ebb03ca943faf96d1dbea030edd (diff)
downloadvyos-1x-e036f783bc85e4d2bad5f5cbfd688a03a352223e.tar.gz
vyos-1x-e036f783bc85e4d2bad5f5cbfd688a03a352223e.zip
image: T4516: add raid-1 install support
Diffstat (limited to 'python/vyos/utils/io.py')
-rw-r--r--python/vyos/utils/io.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/python/vyos/utils/io.py b/python/vyos/utils/io.py
index e34a1ba32..74099b502 100644
--- a/python/vyos/utils/io.py
+++ b/python/vyos/utils/io.py
@@ -13,6 +13,8 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
+from typing import Callable
+
def print_error(str='', end='\n'):
"""
Print `str` to stderr, terminated with `end`.
@@ -73,7 +75,8 @@ def is_dumb_terminal():
import os
return os.getenv('TERM') in ['vt100', 'dumb']
-def select_entry(l: list, list_msg: str = '', prompt_msg: str = '') -> str:
+def select_entry(l: list, list_msg: str = '', prompt_msg: str = '',
+ list_format: Callable = None,) -> str:
"""Select an entry from a list
Args:
@@ -87,7 +90,10 @@ def select_entry(l: list, list_msg: str = '', prompt_msg: str = '') -> str:
en = list(enumerate(l, 1))
print(list_msg)
for i, e in en:
- print(f'\t{i}: {e}')
+ if list_format:
+ print(f'\t{i}: {list_format(e)}')
+ else:
+ print(f'\t{i}: {e}')
select = ask_input(prompt_msg, numeric_only=True,
valid_responses=range(1, len(l)+1))
return next(filter(lambda x: x[0] == select, en))[1]