Use instance method for type_to_text (#4113)

This commit is contained in:
codefiles 2026-01-10 19:29:39 -05:00 committed by GitHub
parent efd57870d0
commit 43509d8ce1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 11 deletions

View File

@ -257,7 +257,7 @@ class DiskLayoutConfigurationMenu(AbstractSubMenu[DiskLayoutConfiguration]):
if enc_config: if enc_config:
enc_type = enc_config.encryption_type 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: if enc_config.encryption_password:
output += tr('Password') + f': {enc_config.encryption_password.hidden()}\n' output += tr('Password') + f': {enc_config.encryption_password.hidden()}\n'

View File

@ -184,7 +184,7 @@ class DiskEncryptionMenu(AbstractSubMenu[DiskEncryption]):
enc_type = self._item_group.find_by_key('encryption_type').value enc_type = self._item_group.find_by_key('encryption_type').value
if enc_type: 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 f'{tr("Encryption type")}: {enc_text}'
return None return None
@ -252,9 +252,9 @@ def select_encryption_type(
if not preset: if not preset:
preset = options[0] 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 = MenuItemGroup(items)
group.set_focus_by_value(preset_value) group.set_focus_by_value(preset_value)

View File

@ -5,7 +5,7 @@ from typing import override
from archinstall.lib.disk.disk_menu import DiskLayoutConfigurationMenu from archinstall.lib.disk.disk_menu import DiskLayoutConfigurationMenu
from archinstall.lib.models.application import ApplicationConfiguration, ZramConfiguration from archinstall.lib.models.application import ApplicationConfiguration, ZramConfiguration
from archinstall.lib.models.authentication import AuthenticationConfiguration 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.lib.packages import list_available_packages
from archinstall.tui.menu_item import MenuItem, MenuItemGroup 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' output += '{}: {}'.format(tr('LVM configuration type'), disk_layout_conf.lvm_config.config_type.display_msg()) + '\n'
if disk_layout_conf.disk_encryption: 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: if disk_layout_conf.btrfs_options:
btrfs_options = disk_layout_conf.btrfs_options btrfs_options = disk_layout_conf.btrfs_options

View File

@ -1444,11 +1444,10 @@ class EncryptionType(Enum):
mapping = cls._encryption_type_mapper() mapping = cls._encryption_type_mapper()
return mapping[text] return mapping[text]
@classmethod def type_to_text(self) -> str:
def type_to_text(cls, type_: 'EncryptionType') -> str: mapping = self._encryption_type_mapper()
mapping = cls._encryption_type_mapper() type_to_text = {enctype: text for text, enctype in mapping.items()}
type_to_text = {type_: text for text, type_ in mapping.items()} return type_to_text[self]
return type_to_text[type_]
class _DiskEncryptionSerialization(TypedDict): class _DiskEncryptionSerialization(TypedDict):