Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/__init__.py1
-rw-r--r--archinstall/lib/storage.py1
-rw-r--r--archinstall/lib/user_interaction.py28
3 files changed, 30 insertions, 0 deletions
diff --git a/archinstall/__init__.py b/archinstall/__init__.py
index ad4220f2..a05b8e95 100644
--- a/archinstall/__init__.py
+++ b/archinstall/__init__.py
@@ -11,3 +11,4 @@ from .lib.locale_helpers import *
from .lib.services import *
from .lib.packages import *
from .lib.output import *
+from .lib.storage import * \ No newline at end of file
diff --git a/archinstall/lib/storage.py b/archinstall/lib/storage.py
new file mode 100644
index 00000000..2c621f83
--- /dev/null
+++ b/archinstall/lib/storage.py
@@ -0,0 +1 @@
+storage = {} \ No newline at end of file
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index 23141fa9..e01859b3 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -5,6 +5,34 @@ from .locale_helpers import search_keyboard_layout
## TODO: Some inconsistencies between the selection processes.
## Some return the keys from the options, some the values?
+def generic_select(options, input_text="Select one of the above by index or absolute value: ", sort=True):
+ """
+ A generic select function that does not output anything
+ other than the options and their indexs. As an example:
+
+ generic_select(["first", "second", "third option"])
+ 1: first
+ 2: second
+ 3: third option
+ """
+
+ if type(options) == dict: options = list(options)
+ if sort: options = sorted(list(options))
+ if len(options) <= 0: raise RequirementError('generic_select() requires at least one option to operate.')
+
+ for index, option in enumerate(options):
+ print(f"{index}: {option}")
+
+ selected_option = input(input_text)
+ if selected_option.isdigit():
+ selected_option = options[int(selected_option)]
+ elif selected_option in options:
+ pass # We gave a correct absolute value
+ else:
+ raise RequirementError(f'Selected option "{selected_option}" does not exist in available options: {options}')
+
+ return selected_option
+
def select_disk(dict_o_disks):
"""
Asks the user to select a harddrive from the `dict_o_disks` selection.