Skip to content

Commit 7214945

Browse files
committed
Use list comprehension
1 parent e7f2a8c commit 7214945

File tree

8 files changed

+16
-21
lines changed

8 files changed

+16
-21
lines changed

archinstall/lib/disk/disk_menu.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from archinstall.tui import MenuItem, MenuItemGroup
44

5-
from ..disk import DeviceModification
65
from ..interactions import select_disk_config
76
from ..interactions.disk_conf import select_lvm_config
87
from ..menu import AbstractSubMenu
@@ -101,8 +100,7 @@ def _prev_disk_layouts(self, item: MenuItem) -> str | None:
101100
msg += str(_('Mountpoint')) + ': ' + str(disk_layout_conf.mountpoint)
102101
return msg
103102

104-
device_mods: list[DeviceModification] = \
105-
list(filter(lambda x: len(x.partitions) > 0, disk_layout_conf.device_modifications))
103+
device_mods = [d for d in disk_layout_conf.device_modifications if d.partitions]
106104

107105
if device_mods:
108106
output_partition = '{}: {}\n'.format(str(_('Configuration')), disk_layout_conf.config_type.display_msg())
@@ -116,9 +114,7 @@ def _prev_disk_layouts(self, item: MenuItem) -> str | None:
116114
output_partition += partition_table + '\n'
117115

118116
# create btrfs table
119-
btrfs_partitions = list(
120-
filter(lambda p: len(p.btrfs_subvols) > 0, mod.partitions)
121-
)
117+
btrfs_partitions = [p for p in mod.partitions if p.btrfs_subvols]
122118
for partition in btrfs_partitions:
123119
output_btrfs += FormattedOutput.as_table(partition.btrfs_subvols) + '\n'
124120

archinstall/lib/disk/encryption_menu.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,10 @@ def select_partitions_to_encrypt(
284284

285285
# do not allow encrypting the boot partition
286286
for mod in modification:
287-
partitions += list(filter(lambda x: x.mountpoint != Path('/boot'), mod.partitions))
287+
partitions += [p for p in mod.partitions if p.mountpoint != Path('/boot')]
288288

289289
# do not allow encrypting existing partitions that are not marked as wipe
290-
avail_partitions = list(filter(lambda x: not x.exists(), partitions))
290+
avail_partitions = [p for p in partitions if not p.exists()]
291291

292292
if avail_partitions:
293293
group, header = MenuHelper.create_table(data=avail_partitions)

archinstall/lib/disk/filesystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def perform_filesystem_operations(self, show_countdown: bool = True) -> None:
4949
debug('Disk layout configuration is set to pre-mount, not performing any operations')
5050
return
5151

52-
device_mods = list(filter(lambda x: len(x.partitions) > 0, self._disk_config.device_modifications))
52+
device_mods = [d for d in self._disk_config.device_modifications if d.partitions]
5353

5454
if not device_mods:
5555
debug('No modifications required')

archinstall/lib/installer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def _mount_partition_layout(self, luks_handlers: dict[Any, Luks2]) -> None:
242242
break
243243

244244
for mod in sorted_device_mods:
245-
not_pv_part_mods = list(filter(lambda x: x not in pvs, mod.partitions))
245+
not_pv_part_mods = [p for p in mod.partitions if p not in pvs]
246246

247247
# partitions have to mounted in the right order on btrfs the mountpoint will
248248
# be empty as the actual subvolumes are getting mounted instead so we'll use

archinstall/lib/interactions/disk_conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ def suggest_multi_disk_layout(
462462
filesystem_type = select_main_filesystem_format(advanced_options)
463463

464464
# find proper disk for /home
465-
possible_devices = list(filter(lambda x: x.device_info.total_size >= min_home_partition_size, devices))
465+
possible_devices = [d for d in devices if d.device_info.total_size >= min_home_partition_size]
466466
home_device = max(possible_devices, key=lambda d: d.device_info.total_size) if possible_devices else None
467467

468468
# find proper device for /root

archinstall/lib/profile/profiles_handler.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,21 +164,20 @@ def get_profile_by_name(self, name: str) -> Profile | None:
164164
return next(filter(lambda x: x.name == name, self.profiles), None) # type: ignore
165165

166166
def get_top_level_profiles(self) -> list[Profile]:
167-
return list(filter(lambda x: x.is_top_level_profile(), self.profiles))
167+
return [p for p in self.profiles if p.is_top_level_profile()]
168168

169169
def get_server_profiles(self) -> list[Profile]:
170-
return list(filter(lambda x: x.is_server_type_profile(), self.profiles))
170+
return [p for p in self.profiles if p.is_server_type_profile()]
171171

172172
def get_desktop_profiles(self) -> list[Profile]:
173-
return list(filter(lambda x: x.is_desktop_type_profile(), self.profiles))
173+
return [p for p in self.profiles if p.is_desktop_type_profile()]
174174

175175
def get_custom_profiles(self) -> list[Profile]:
176-
return list(filter(lambda x: x.is_custom_type_profile(), self.profiles))
176+
return [p for p in self.profiles if p.is_custom_type_profile()]
177177

178178
def get_mac_addr_profiles(self) -> list[Profile]:
179-
tailored = list(filter(lambda x: x.is_tailored(), self.profiles))
180-
match_mac_addr_profiles = list(filter(lambda x: x.name in self._local_mac_addresses, tailored))
181-
return match_mac_addr_profiles
179+
tailored = [p for p in self.profiles if p.is_tailored()]
180+
return [t for t in tailored if t.name in self._local_mac_addresses]
182181

183182
def install_greeter(self, install_session: 'Installer', greeter: GreeterType) -> None:
184183
packages = []
@@ -296,7 +295,7 @@ def _verify_unique_profile_names(self, profiles: list[Profile]) -> None:
296295
that the provided list contains only default_profiles with unique names
297296
"""
298297
counter = Counter([p.name for p in profiles])
299-
duplicates = list(filter(lambda x: x[1] != 1, counter.items()))
298+
duplicates = [x for x in counter.items() if x[1] != 1]
300299

301300
if len(duplicates) > 0:
302301
err = str(_('Profiles must have unique name, but profile definitions with duplicate name found: {}')).format(duplicates[0][0])

archinstall/scripts/minimal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def parse_disk_encryption() -> None:
7474

7575
# encrypt all partitions except the /boot
7676
for mod in modification:
77-
partitions += list(filter(lambda x: x.mountpoint != Path('/boot'), mod.partitions))
77+
partitions += [p for p in mod.partitions if p.mountpoint != Path('/boot')]
7878

7979
archinstall.arguments['disk_encryption'] = disk.DiskEncryption(
8080
encryption_type=disk.EncryptionType.Luks,

examples/minimal_installation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def parse_disk_encryption() -> None:
7474

7575
# encrypt all partitions except the /boot
7676
for mod in modification:
77-
partitions += list(filter(lambda x: x.mountpoint != Path('/boot'), mod.partitions))
77+
partitions += [p for p in mod.partitions if p.mountpoint != Path('/boot')]
7878

7979
archinstall.arguments['disk_encryption'] = disk.DiskEncryption(
8080
encryption_type=disk.EncryptionType.Luks,

0 commit comments

Comments
 (0)