Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/helpers/user_interaction.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds+github@gmail.com>2020-06-29 08:55:25 +0000
committerAnton Hvornum <anton.feeds+github@gmail.com>2020-06-29 08:55:25 +0000
commit5ae18b80fd118cc07108694feb81e5e02a9b18f3 (patch)
treeae19f5234e465492044052a8ef4bf6029e42c1d3 /helpers/user_interaction.py
parent89ecdee763677fd455fc9ae722632928047a791d (diff)
Starting to rework the entire codebase to be context friendly. Annotations is next after one successful install.
Diffstat (limited to 'helpers/user_interaction.py')
-rw-r--r--helpers/user_interaction.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/helpers/user_interaction.py b/helpers/user_interaction.py
new file mode 100644
index 00000000..1b7e85cf
--- /dev/null
+++ b/helpers/user_interaction.py
@@ -0,0 +1,17 @@
+from exceptions import *
+
+def select_disk(dict_o_disks):
+ drives = sorted(list(dict_o_disks.keys()))
+ if len(drives) > 1:
+ for index, drive in enumerate(drives):
+ print(f"{index}: {drive} ({dict_o_disks[drive]['size'], dict_o_disks[drive]['backplane'], dict_o_disks[drive]['label']})")
+ drive = input('Select one of the above disks (by number or full path): ')
+ if drive.isdigit():
+ drive = dict_o_disks[drives[int(drive)]]
+ elif drive in dict_o_disks:
+ drive = dict_o_disks[drive]
+ else:
+ raise DiskError(f'Selected drive does not exist: "{drive}"')
+ return drive
+
+ raise DiskError('select_disk() requires a non-empty dictionary of disks to select from.') \ No newline at end of file