Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archinstall/lib/locale_helpers.py6
-rw-r--r--archinstall/lib/user_interaction.py46
2 files changed, 35 insertions, 17 deletions
diff --git a/archinstall/lib/locale_helpers.py b/archinstall/lib/locale_helpers.py
index 736bfc47..3c373bc6 100644
--- a/archinstall/lib/locale_helpers.py
+++ b/archinstall/lib/locale_helpers.py
@@ -16,6 +16,12 @@ def list_keyboard_languages():
if os.path.splitext(file)[1] == '.gz':
yield file.strip('.gz').strip('.map')
+def verify_keyboard_layout(layout):
+ for language in list_keyboard_languages():
+ if layout.lower() == language.lower():
+ return True
+ return False
+
def search_keyboard_layout(filter):
for language in list_keyboard_languages():
if filter.lower() in language.lower():
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index fc62f44c..dcb51e2a 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -2,7 +2,7 @@ import getpass, pathlib, os, shutil, re
import sys, time, signal, ipaddress
from .exceptions import *
from .profiles import Profile
-from .locale_helpers import search_keyboard_layout
+from .locale_helpers import list_keyboard_languages, verify_keyboard_layout, search_keyboard_layout
from .output import log, LOG_LEVELS
from .storage import storage
from .networking import list_interfaces
@@ -130,17 +130,18 @@ def ask_for_additional_users(prompt='Any additional users to install (leave blan
return users, super_users
def ask_for_a_timezone():
- timezone = input('Enter a valid timezone (examples: Europe/Stockholm, US/Eastern) or press enter to use UTC: ').strip()
- if timezone == '':
- timezone = 'UTC'
- if (pathlib.Path("/usr")/"share"/"zoneinfo"/timezone).exists():
- return timezone
- else:
- log(
- f"Time zone {timezone} does not exist, continuing with system default.",
- level=LOG_LEVELS.Warning,
- fg='red'
- )
+ while True:
+ timezone = input('Enter a valid timezone (examples: Europe/Stockholm, US/Eastern) or press enter to use UTC: ').strip()
+ if timezone == '':
+ timezone = 'UTC'
+ if (pathlib.Path("/usr")/"share"/"zoneinfo"/timezone).exists():
+ return timezone
+ else:
+ log(
+ f"Specified timezone {timezone} does not exist.",
+ level=LOG_LEVELS.Warning,
+ fg='red'
+ )
def ask_for_audio_selection():
audio = "pulseaudio" # Default for most desktop environments
@@ -360,10 +361,13 @@ def select_language(options, show_only_country_codes=True):
"""
Asks the user to select a language from the `options` dictionary parameter.
Usually this is combined with :ref:`archinstall.list_keyboard_languages`.
- :param options: A `dict` where keys are the language name, value should be a dict containing language information.
- :type options: dict
+
+ :param options: A `generator` or `list` where keys are the language name, value should be a dict containing language information.
+ :type options: generator or list
+
:param show_only_country_codes: Filters out languages that are not len(lang) == 2. This to limit the number of results from stuff like dvorak and x-latin1 alternatives.
:type show_only_country_codes: bool
+
:return: The language/dictionary key of the selected language
:rtype: str
"""
@@ -387,11 +391,17 @@ def select_language(options, show_only_country_codes=True):
return DEFAULT_KEYBOARD_LANGUAGE
elif selected_language.lower() in ('?', 'help'):
while True:
- filter_string = input('Search for layout containing (example: "sv-"): ')
+ filter_string = input("Search for layout containing (example: \"sv-\") or enter 'exit' to exit from search: ")
+
+ if filter_string.lower() == 'exit':
+ return select_language(list_keyboard_languages())
+
new_options = list(search_keyboard_layout(filter_string))
+
if len(new_options) <= 0:
- log(f"Search string '{filter_string}' yielded no results, please try another search or Ctrl+D to abort.", fg='yellow')
+ log(f"Search string '{filter_string}' yielded no results, please try another search.", fg='yellow')
continue
+
return select_language(new_options, show_only_country_codes=False)
elif selected_language.isnumeric():
selected_language = int(selected_language)
@@ -399,11 +409,13 @@ def select_language(options, show_only_country_codes=True):
log(' * Selected option is out of range * ', fg='red')
continue
return languages[selected_language]
- elif search_keyboard_layout(selected_language):
+ elif verify_keyboard_layout(selected_language):
return selected_language
else:
log(" * Given language wasn't found * ", fg='red')
+ raise RequirementError("Selecting languages require a least one language to be given as an option.")
+
def select_mirror_regions(mirrors, show_top_mirrors=True):
"""
Asks the user to select a mirror or region from the `mirrors` dictionary parameter.