From 429006fe4b2775d4f28cfaa4ad86028fac56dccd Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 4 Sep 2021 17:03:52 +0200 Subject: Simplified lambda and made it filter out non relevant disks for the selection process. --- archinstall/lib/disk.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'archinstall/lib') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 4a5b2f4c..bac46c3a 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -75,6 +75,11 @@ def sort_block_devices_based_on_performance(block_devices): return result +def filter_disks_below_size_in_gb(devices, gigabytes): + for disk in devices: + if disk.size >= gigabytes: + yield disk + def select_largest_device(devices, gigabytes, filter_out=None): if not filter_out: filter_out = [] @@ -84,10 +89,12 @@ def select_largest_device(devices, gigabytes, filter_out=None): if filter_device in copy_devices: copy_devices.pop(copy_devices.index(filter_device)) + copy_devices = list(filter_disks_below_size_in_gb(copy_devices, gigabytes)) + if not len(copy_devices): return None - return max(copy_devices, key=(lambda device : device.size if device.size > gigabytes else 0)) + return max(copy_devices, key=(lambda device : device.size)) def select_disk_larger_than_or_close_to(devices, gigabytes, filter_out=None): if not filter_out: -- cgit v1.2.3-70-g09d2