Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/menu/menu.py19
-rw-r--r--archinstall/lib/translation.py8
-rw-r--r--archinstall/lib/user_interaction.py31
3 files changed, 40 insertions, 18 deletions
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)
diff --git a/archinstall/lib/translation.py b/archinstall/lib/translation.py
index b8a27fed..767d6d36 100644
--- a/archinstall/lib/translation.py
+++ b/archinstall/lib/translation.py
@@ -8,6 +8,7 @@ from pathlib import Path
from typing import List, Dict
from .exceptions import TranslationError
+
class Languages:
def __init__(self):
self._mappings = self._get_language_mappings()
@@ -46,6 +47,13 @@ class DeferredTranslation:
def __gt__(self, other) -> bool:
return self.message > other
+ def __add__(self, other) -> DeferredTranslation:
+ if isinstance(other, str):
+ other = DeferredTranslation(other)
+
+ concat = self.message + other.message
+ return DeferredTranslation(concat)
+
def format(self, *args) -> str:
return self.message.format(*args)
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index f8822bac..94a05e89 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -30,7 +30,7 @@ from .mirrors import list_mirrors
# TODO: Some inconsistencies between the selection processes.
# Some return the keys from the options, some the values?
-from .translation import Translation
+from .translation import Translation, DeferredTranslation
from .disk.validators import fs_types
from .packages.packages import validate_package_list
@@ -428,22 +428,22 @@ def ask_to_configure_network() -> Dict[str, Any]:
# Optionally configure one network interface.
# while 1:
# {MAC: Ifname}
-
- iso_config = _('Copy ISO network configuration to installation')
- network_manager = _('Use NetworkManager (necessary to configure internet graphically in GNOME and KDE)')
-
interfaces = {
- 'ISO-CONFIG': iso_config,
- 'NetworkManager': network_manager,
+ 'iso_config': str(_('Copy ISO network configuration to installation')),
+ 'network_manager': str(_('Use NetworkManager (necessary to configure internet graphically in GNOME and KDE)')),
**list_interfaces()
}
nic = Menu(_('Select one network interface to configure'), list(interfaces.values())).run()
- if nic and nic != iso_config:
- if nic == network_manager:
- return {'nic': nic, 'NetworkManager': True}
+ if not nic:
+ return {}
+ if nic == interfaces['iso_config']:
+ return {'type': 'iso_config'}
+ elif nic == interfaces['network_manager']:
+ return {'type': 'network_manager', 'NetworkManager': True}
+ else:
# Current workaround:
# For selecting modes without entering text within brackets,
# printing out this part separate from options, passed in
@@ -491,13 +491,10 @@ def ask_to_configure_network() -> Dict[str, Any]:
if len(dns_input):
dns = dns_input.split(' ')
- return {'nic': nic, 'dhcp': False, 'ip': ip, 'gateway': gateway, 'dns': dns}
+ return {'type': nic, 'dhcp': False, 'ip': ip, 'gateway': gateway, 'dns': dns}
else:
- return {'nic': nic}
- elif nic:
- return nic
-
- return {}
+ # this will contain network iface names
+ return {'type': nic}
def partition_overlap(partitions :list, start :str, end :str) -> bool:
@@ -925,7 +922,7 @@ def select_driver(options :Dict[str, Any] = AVAILABLE_GFX_DRIVERS, force_ask :bo
if drivers:
arguments = storage.get('arguments', {})
- title = ''
+ title = DeferredTranslation('')
if has_amd_graphics():
title += _('For the best compatibility with your AMD hardware, you may want to use either the all open-source or AMD / ATI options.') + '\n'