Skip to content

Commit 43509d8

Browse files
authored
Use instance method for type_to_text (archlinux#4113)
1 parent efd5787 commit 43509d8

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

archinstall/lib/disk/disk_menu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def _prev_disk_encryption(self, item: MenuItem) -> str | None:
257257

258258
if enc_config:
259259
enc_type = enc_config.encryption_type
260-
output = tr('Encryption type') + f': {EncryptionType.type_to_text(enc_type)}\n'
260+
output = tr('Encryption type') + f': {enc_type.type_to_text()}\n'
261261

262262
if enc_config.encryption_password:
263263
output += tr('Password') + f': {enc_config.encryption_password.hidden()}\n'

archinstall/lib/disk/encryption_menu.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def _prev_type(self) -> str | None:
184184
enc_type = self._item_group.find_by_key('encryption_type').value
185185

186186
if enc_type:
187-
enc_text = EncryptionType.type_to_text(enc_type)
187+
enc_text = enc_type.type_to_text()
188188
return f'{tr("Encryption type")}: {enc_text}'
189189

190190
return None
@@ -252,9 +252,9 @@ def select_encryption_type(
252252
if not preset:
253253
preset = options[0]
254254

255-
preset_value = EncryptionType.type_to_text(preset)
255+
preset_value = preset.type_to_text()
256256

257-
items = [MenuItem(EncryptionType.type_to_text(o), value=o) for o in options]
257+
items = [MenuItem(o.type_to_text(), value=o) for o in options]
258258
group = MenuItemGroup(items)
259259
group.set_focus_by_value(preset_value)
260260

archinstall/lib/global_menu.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from archinstall.lib.disk.disk_menu import DiskLayoutConfigurationMenu
66
from archinstall.lib.models.application import ApplicationConfiguration, ZramConfiguration
77
from archinstall.lib.models.authentication import AuthenticationConfiguration
8-
from archinstall.lib.models.device import DiskLayoutConfiguration, DiskLayoutType, EncryptionType, FilesystemType, PartitionModification
8+
from archinstall.lib.models.device import DiskLayoutConfiguration, DiskLayoutType, FilesystemType, PartitionModification
99
from archinstall.lib.packages import list_available_packages
1010
from archinstall.tui.menu_item import MenuItem, MenuItemGroup
1111

@@ -375,7 +375,7 @@ def _prev_disk_config(self, item: MenuItem) -> str | None:
375375
output += '{}: {}'.format(tr('LVM configuration type'), disk_layout_conf.lvm_config.config_type.display_msg()) + '\n'
376376

377377
if disk_layout_conf.disk_encryption:
378-
output += tr('Disk encryption') + ': ' + EncryptionType.type_to_text(disk_layout_conf.disk_encryption.encryption_type) + '\n'
378+
output += tr('Disk encryption') + ': ' + disk_layout_conf.disk_encryption.encryption_type.type_to_text() + '\n'
379379

380380
if disk_layout_conf.btrfs_options:
381381
btrfs_options = disk_layout_conf.btrfs_options

archinstall/lib/models/device.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,11 +1444,10 @@ def text_to_type(cls, text: str) -> 'EncryptionType':
14441444
mapping = cls._encryption_type_mapper()
14451445
return mapping[text]
14461446

1447-
@classmethod
1448-
def type_to_text(cls, type_: 'EncryptionType') -> str:
1449-
mapping = cls._encryption_type_mapper()
1450-
type_to_text = {type_: text for text, type_ in mapping.items()}
1451-
return type_to_text[type_]
1447+
def type_to_text(self) -> str:
1448+
mapping = self._encryption_type_mapper()
1449+
type_to_text = {enctype: text for text, enctype in mapping.items()}
1450+
return type_to_text[self]
14521451

14531452

14541453
class _DiskEncryptionSerialization(TypedDict):

0 commit comments

Comments
 (0)