index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Daniel <blackrabbit256@gmail.com> | 2022-02-15 18:44:58 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-15 08:44:58 +0100 |
commit | 6489a417aa8d43bd58ec0fd1268d0dd734b0073f (patch) | |
tree | 476033ff0d6a2650ff5202f42b248e7b4bbe2f8d /archinstall/lib/menu | |
parent | d9118a33b3a25839fde8626cde313115ddb79376 (diff) |
-rw-r--r-- | archinstall/lib/menu/menu.py | 19 |
diff --git a/archinstall/lib/menu/menu.py b/archinstall/lib/menu/menu.py index ac075b66..ee4b87e3 100644 --- a/archinstall/lib/menu/menu.py +++ b/archinstall/lib/menu/menu.py @@ -1,3 +1,5 @@ +from typing import Dict, List, Union, Any + from archinstall.lib.menu.simple_menu import TerminalMenu from ..exceptions import RequirementError from ..output import log @@ -7,7 +9,17 @@ import sys import logging class Menu(TerminalMenu): - def __init__(self, title, p_options, skip=True, multi=False, default_option=None, sort=True, preset_values=None, cursor_index=None): + def __init__( + self, + title :str, + p_options :Union[List[str], Dict[str, Any]], + skip :bool = True, + multi :bool = False, + default_option :str = None, + sort :bool = True, + preset_values :Union[str, List[str]] = None, + cursor_index :int = None + ): """ Creates a new menu @@ -60,6 +72,11 @@ class Menu(TerminalMenu): log(f"invalid parameter at Menu() call was at <{sys._getframe(1).f_code.co_name}>",level=logging.WARNING) raise RequirementError('Menu.__init__() requires at least one option to proceed.') + if any([o for o in options if not isinstance(o, str)]): + log(" * Menu options must be of type string * ", fg='red') + log(f"invalid parameter at Menu() call was at <{sys._getframe(1).f_code.co_name}>",level=logging.WARNING) + raise RequirementError('Menu.__init__() requires the options to be of type string') + if sort: options = sorted(options) |