Use instance method for type_to_text (#4113)
This commit is contained in:
parent
efd57870d0
commit
43509d8ce1
|
|
@ -257,7 +257,7 @@ class DiskLayoutConfigurationMenu(AbstractSubMenu[DiskLayoutConfiguration]):
|
|||
|
||||
if enc_config:
|
||||
enc_type = enc_config.encryption_type
|
||||
output = tr('Encryption type') + f': {EncryptionType.type_to_text(enc_type)}\n'
|
||||
output = tr('Encryption type') + f': {enc_type.type_to_text()}\n'
|
||||
|
||||
if enc_config.encryption_password:
|
||||
output += tr('Password') + f': {enc_config.encryption_password.hidden()}\n'
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ class DiskEncryptionMenu(AbstractSubMenu[DiskEncryption]):
|
|||
enc_type = self._item_group.find_by_key('encryption_type').value
|
||||
|
||||
if enc_type:
|
||||
enc_text = EncryptionType.type_to_text(enc_type)
|
||||
enc_text = enc_type.type_to_text()
|
||||
return f'{tr("Encryption type")}: {enc_text}'
|
||||
|
||||
return None
|
||||
|
|
@ -252,9 +252,9 @@ def select_encryption_type(
|
|||
if not preset:
|
||||
preset = options[0]
|
||||
|
||||
preset_value = EncryptionType.type_to_text(preset)
|
||||
preset_value = preset.type_to_text()
|
||||
|
||||
items = [MenuItem(EncryptionType.type_to_text(o), value=o) for o in options]
|
||||
items = [MenuItem(o.type_to_text(), value=o) for o in options]
|
||||
group = MenuItemGroup(items)
|
||||
group.set_focus_by_value(preset_value)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from typing import override
|
|||
from archinstall.lib.disk.disk_menu import DiskLayoutConfigurationMenu
|
||||
from archinstall.lib.models.application import ApplicationConfiguration, ZramConfiguration
|
||||
from archinstall.lib.models.authentication import AuthenticationConfiguration
|
||||
from archinstall.lib.models.device import DiskLayoutConfiguration, DiskLayoutType, EncryptionType, FilesystemType, PartitionModification
|
||||
from archinstall.lib.models.device import DiskLayoutConfiguration, DiskLayoutType, FilesystemType, PartitionModification
|
||||
from archinstall.lib.packages import list_available_packages
|
||||
from archinstall.tui.menu_item import MenuItem, MenuItemGroup
|
||||
|
||||
|
|
@ -375,7 +375,7 @@ class GlobalMenu(AbstractMenu[None]):
|
|||
output += '{}: {}'.format(tr('LVM configuration type'), disk_layout_conf.lvm_config.config_type.display_msg()) + '\n'
|
||||
|
||||
if disk_layout_conf.disk_encryption:
|
||||
output += tr('Disk encryption') + ': ' + EncryptionType.type_to_text(disk_layout_conf.disk_encryption.encryption_type) + '\n'
|
||||
output += tr('Disk encryption') + ': ' + disk_layout_conf.disk_encryption.encryption_type.type_to_text() + '\n'
|
||||
|
||||
if disk_layout_conf.btrfs_options:
|
||||
btrfs_options = disk_layout_conf.btrfs_options
|
||||
|
|
|
|||
|
|
@ -1444,11 +1444,10 @@ class EncryptionType(Enum):
|
|||
mapping = cls._encryption_type_mapper()
|
||||
return mapping[text]
|
||||
|
||||
@classmethod
|
||||
def type_to_text(cls, type_: 'EncryptionType') -> str:
|
||||
mapping = cls._encryption_type_mapper()
|
||||
type_to_text = {type_: text for text, type_ in mapping.items()}
|
||||
return type_to_text[type_]
|
||||
def type_to_text(self) -> str:
|
||||
mapping = self._encryption_type_mapper()
|
||||
type_to_text = {enctype: text for text, enctype in mapping.items()}
|
||||
return type_to_text[self]
|
||||
|
||||
|
||||
class _DiskEncryptionSerialization(TypedDict):
|
||||
|
|
|
|||
Loading…
Reference in New Issue