Use list comprehension (#3105)
This commit is contained in:
parent
7202d964dd
commit
3409f84e79
|
|
@ -2,7 +2,6 @@ from typing import TYPE_CHECKING, Any, override
|
||||||
|
|
||||||
from archinstall.tui import MenuItem, MenuItemGroup
|
from archinstall.tui import MenuItem, MenuItemGroup
|
||||||
|
|
||||||
from ..disk import DeviceModification
|
|
||||||
from ..interactions import select_disk_config
|
from ..interactions import select_disk_config
|
||||||
from ..interactions.disk_conf import select_lvm_config
|
from ..interactions.disk_conf import select_lvm_config
|
||||||
from ..menu import AbstractSubMenu
|
from ..menu import AbstractSubMenu
|
||||||
|
|
@ -101,8 +100,7 @@ class DiskLayoutConfigurationMenu(AbstractSubMenu):
|
||||||
msg += str(_('Mountpoint')) + ': ' + str(disk_layout_conf.mountpoint)
|
msg += str(_('Mountpoint')) + ': ' + str(disk_layout_conf.mountpoint)
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
device_mods: list[DeviceModification] = \
|
device_mods = [d for d in disk_layout_conf.device_modifications if d.partitions]
|
||||||
list(filter(lambda x: len(x.partitions) > 0, disk_layout_conf.device_modifications))
|
|
||||||
|
|
||||||
if device_mods:
|
if device_mods:
|
||||||
output_partition = '{}: {}\n'.format(str(_('Configuration')), disk_layout_conf.config_type.display_msg())
|
output_partition = '{}: {}\n'.format(str(_('Configuration')), disk_layout_conf.config_type.display_msg())
|
||||||
|
|
@ -116,9 +114,7 @@ class DiskLayoutConfigurationMenu(AbstractSubMenu):
|
||||||
output_partition += partition_table + '\n'
|
output_partition += partition_table + '\n'
|
||||||
|
|
||||||
# create btrfs table
|
# create btrfs table
|
||||||
btrfs_partitions = list(
|
btrfs_partitions = [p for p in mod.partitions if p.btrfs_subvols]
|
||||||
filter(lambda p: len(p.btrfs_subvols) > 0, mod.partitions)
|
|
||||||
)
|
|
||||||
for partition in btrfs_partitions:
|
for partition in btrfs_partitions:
|
||||||
output_btrfs += FormattedOutput.as_table(partition.btrfs_subvols) + '\n'
|
output_btrfs += FormattedOutput.as_table(partition.btrfs_subvols) + '\n'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -284,10 +284,10 @@ def select_partitions_to_encrypt(
|
||||||
|
|
||||||
# do not allow encrypting the boot partition
|
# do not allow encrypting the boot partition
|
||||||
for mod in modification:
|
for mod in modification:
|
||||||
partitions += list(filter(lambda x: x.mountpoint != Path('/boot'), mod.partitions))
|
partitions += [p for p in mod.partitions if p.mountpoint != Path('/boot')]
|
||||||
|
|
||||||
# do not allow encrypting existing partitions that are not marked as wipe
|
# do not allow encrypting existing partitions that are not marked as wipe
|
||||||
avail_partitions = list(filter(lambda x: not x.exists(), partitions))
|
avail_partitions = [p for p in partitions if not p.exists()]
|
||||||
|
|
||||||
if avail_partitions:
|
if avail_partitions:
|
||||||
group, header = MenuHelper.create_table(data=avail_partitions)
|
group, header = MenuHelper.create_table(data=avail_partitions)
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class FilesystemHandler:
|
||||||
debug('Disk layout configuration is set to pre-mount, not performing any operations')
|
debug('Disk layout configuration is set to pre-mount, not performing any operations')
|
||||||
return
|
return
|
||||||
|
|
||||||
device_mods = list(filter(lambda x: len(x.partitions) > 0, self._disk_config.device_modifications))
|
device_mods = [d for d in self._disk_config.device_modifications if d.partitions]
|
||||||
|
|
||||||
if not device_mods:
|
if not device_mods:
|
||||||
debug('No modifications required')
|
debug('No modifications required')
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,7 @@ class Installer:
|
||||||
break
|
break
|
||||||
|
|
||||||
for mod in sorted_device_mods:
|
for mod in sorted_device_mods:
|
||||||
not_pv_part_mods = list(filter(lambda x: x not in pvs, mod.partitions))
|
not_pv_part_mods = [p for p in mod.partitions if p not in pvs]
|
||||||
|
|
||||||
# partitions have to mounted in the right order on btrfs the mountpoint will
|
# partitions have to mounted in the right order on btrfs the mountpoint will
|
||||||
# be empty as the actual subvolumes are getting mounted instead so we'll use
|
# be empty as the actual subvolumes are getting mounted instead so we'll use
|
||||||
|
|
|
||||||
|
|
@ -462,7 +462,7 @@ def suggest_multi_disk_layout(
|
||||||
filesystem_type = select_main_filesystem_format(advanced_options)
|
filesystem_type = select_main_filesystem_format(advanced_options)
|
||||||
|
|
||||||
# find proper disk for /home
|
# find proper disk for /home
|
||||||
possible_devices = list(filter(lambda x: x.device_info.total_size >= min_home_partition_size, devices))
|
possible_devices = [d for d in devices if d.device_info.total_size >= min_home_partition_size]
|
||||||
home_device = max(possible_devices, key=lambda d: d.device_info.total_size) if possible_devices else None
|
home_device = max(possible_devices, key=lambda d: d.device_info.total_size) if possible_devices else None
|
||||||
|
|
||||||
# find proper device for /root
|
# find proper device for /root
|
||||||
|
|
|
||||||
|
|
@ -164,21 +164,20 @@ class ProfileHandler:
|
||||||
return next(filter(lambda x: x.name == name, self.profiles), None) # type: ignore
|
return next(filter(lambda x: x.name == name, self.profiles), None) # type: ignore
|
||||||
|
|
||||||
def get_top_level_profiles(self) -> list[Profile]:
|
def get_top_level_profiles(self) -> list[Profile]:
|
||||||
return list(filter(lambda x: x.is_top_level_profile(), self.profiles))
|
return [p for p in self.profiles if p.is_top_level_profile()]
|
||||||
|
|
||||||
def get_server_profiles(self) -> list[Profile]:
|
def get_server_profiles(self) -> list[Profile]:
|
||||||
return list(filter(lambda x: x.is_server_type_profile(), self.profiles))
|
return [p for p in self.profiles if p.is_server_type_profile()]
|
||||||
|
|
||||||
def get_desktop_profiles(self) -> list[Profile]:
|
def get_desktop_profiles(self) -> list[Profile]:
|
||||||
return list(filter(lambda x: x.is_desktop_type_profile(), self.profiles))
|
return [p for p in self.profiles if p.is_desktop_type_profile()]
|
||||||
|
|
||||||
def get_custom_profiles(self) -> list[Profile]:
|
def get_custom_profiles(self) -> list[Profile]:
|
||||||
return list(filter(lambda x: x.is_custom_type_profile(), self.profiles))
|
return [p for p in self.profiles if p.is_custom_type_profile()]
|
||||||
|
|
||||||
def get_mac_addr_profiles(self) -> list[Profile]:
|
def get_mac_addr_profiles(self) -> list[Profile]:
|
||||||
tailored = list(filter(lambda x: x.is_tailored(), self.profiles))
|
tailored = [p for p in self.profiles if p.is_tailored()]
|
||||||
match_mac_addr_profiles = list(filter(lambda x: x.name in self._local_mac_addresses, tailored))
|
return [t for t in tailored if t.name in self._local_mac_addresses]
|
||||||
return match_mac_addr_profiles
|
|
||||||
|
|
||||||
def install_greeter(self, install_session: 'Installer', greeter: GreeterType) -> None:
|
def install_greeter(self, install_session: 'Installer', greeter: GreeterType) -> None:
|
||||||
packages = []
|
packages = []
|
||||||
|
|
@ -296,7 +295,7 @@ class ProfileHandler:
|
||||||
that the provided list contains only default_profiles with unique names
|
that the provided list contains only default_profiles with unique names
|
||||||
"""
|
"""
|
||||||
counter = Counter([p.name for p in profiles])
|
counter = Counter([p.name for p in profiles])
|
||||||
duplicates = list(filter(lambda x: x[1] != 1, counter.items()))
|
duplicates = [x for x in counter.items() if x[1] != 1]
|
||||||
|
|
||||||
if len(duplicates) > 0:
|
if len(duplicates) > 0:
|
||||||
err = str(_('Profiles must have unique name, but profile definitions with duplicate name found: {}')).format(duplicates[0][0])
|
err = str(_('Profiles must have unique name, but profile definitions with duplicate name found: {}')).format(duplicates[0][0])
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ def parse_disk_encryption() -> None:
|
||||||
|
|
||||||
# encrypt all partitions except the /boot
|
# encrypt all partitions except the /boot
|
||||||
for mod in modification:
|
for mod in modification:
|
||||||
partitions += list(filter(lambda x: x.mountpoint != Path('/boot'), mod.partitions))
|
partitions += [p for p in mod.partitions if p.mountpoint != Path('/boot')]
|
||||||
|
|
||||||
archinstall.arguments['disk_encryption'] = disk.DiskEncryption(
|
archinstall.arguments['disk_encryption'] = disk.DiskEncryption(
|
||||||
encryption_type=disk.EncryptionType.Luks,
|
encryption_type=disk.EncryptionType.Luks,
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ def parse_disk_encryption() -> None:
|
||||||
|
|
||||||
# encrypt all partitions except the /boot
|
# encrypt all partitions except the /boot
|
||||||
for mod in modification:
|
for mod in modification:
|
||||||
partitions += list(filter(lambda x: x.mountpoint != Path('/boot'), mod.partitions))
|
partitions += [p for p in mod.partitions if p.mountpoint != Path('/boot')]
|
||||||
|
|
||||||
archinstall.arguments['disk_encryption'] = disk.DiskEncryption(
|
archinstall.arguments['disk_encryption'] = disk.DiskEncryption(
|
||||||
encryption_type=disk.EncryptionType.Luks,
|
encryption_type=disk.EncryptionType.Luks,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue