Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/user_interaction/subvolume_config.py
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib/user_interaction/subvolume_config.py')
-rw-r--r--archinstall/lib/user_interaction/subvolume_config.py36
1 files changed, 26 insertions, 10 deletions
diff --git a/archinstall/lib/user_interaction/subvolume_config.py b/archinstall/lib/user_interaction/subvolume_config.py
index 0515876b..af783639 100644
--- a/archinstall/lib/user_interaction/subvolume_config.py
+++ b/archinstall/lib/user_interaction/subvolume_config.py
@@ -1,9 +1,11 @@
-from typing import List, Any, Dict
+from typing import Dict, List
from ..menu.list_manager import ListManager
+from ..menu.menu import MenuSelectionType
from ..menu.selection_menu import Selector, GeneralMenu
from ..menu.text_input import TextInput
from ..menu import Menu
+
"""
UI classes
"""
@@ -14,7 +16,7 @@ class SubvolumeList(ListManager):
self.ObjectDefaultAction = str(_('Add'))
super().__init__(prompt,list,None,self.ObjectNullAction,self.ObjectDefaultAction)
- def reformat(self, data: Any) -> List[Any]:
+ def reformat(self, data: Dict) -> Dict:
def presentation(key :str, value :Dict):
text = _(" Subvolume :{:16}").format(key)
if isinstance(value,str):
@@ -24,18 +26,20 @@ class SubvolumeList(ListManager):
text += _(" mounted at {:16}").format(value['mountpoint'])
else:
text += (' ' * 28)
+
if value.get('options',[]):
text += _(" with option {}").format(', '.join(value['options']))
return text
- return sorted(list(map(lambda x:presentation(x,data[x]),data)))
+ formatted = {presentation(k, v): k for k, v in data.items()}
+ return {k: v for k, v in sorted(formatted.items(), key=lambda e: e[0])}
def action_list(self):
return super().action_list()
- def exec_action(self, data: Any):
+ def exec_action(self, data: Dict):
if self.target:
- origkey,origval = list(self.target.items())[0]
+ origkey, origval = list(self.target.items())[0]
else:
origkey = None
@@ -46,13 +50,15 @@ class SubvolumeList(ListManager):
self.target = {}
print(_('\n Fill the desired values for a new subvolume \n'))
with SubvolumeMenu(self.target,self.action) as add_menu:
- for data in ['name','mountpoint','options']:
- add_menu.exec_option(data)
+ for elem in ['name','mountpoint','options']:
+ add_menu.exec_option(elem)
else:
SubvolumeMenu(self.target,self.action).run()
data.update(self.target)
+ return data
+
class SubvolumeMenu(GeneralMenu):
def __init__(self,parameters,action=None):
@@ -124,7 +130,17 @@ class SubvolumeMenu(GeneralMenu):
def _select_subvolume_mount_point(self,value):
return TextInput(str(_("Select a mount point :")),value).run()
- def _select_subvolume_options(self,value):
+ def _select_subvolume_options(self,value) -> List[str]:
# def __init__(self, title, p_options, skip=True, multi=False, default_option=None, sort=True):
- return Menu(str(_("Select the desired subvolume options ")),['nodatacow','compress'],
- skip=True,preset_values=value,multi=True).run()
+ choice = Menu(
+ str(_("Select the desired subvolume options ")),
+ ['nodatacow','compress'],
+ skip=True,
+ preset_values=value,
+ multi=True
+ ).run()
+
+ if choice.type_ == MenuSelectionType.Selection:
+ return choice.value
+
+ return []