1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-05 18:30:50 +01:00

Fixed issue where non-consecutive list resulted in incorrect ranges

For example if `[3,1,2]` was provided, it would result in `3,1-2`, but after writing this to a sysfs file, it would read back as `1-3`
This commit is contained in:
Sebastian Goscik 2024-03-27 11:34:08 +00:00 committed by Marc Bonnici
parent 8247ac91e7
commit 5817866ad0

View File

@ -655,6 +655,7 @@ def ranges_to_list(ranges_string):
def list_to_ranges(values):
"""Converts a list, e.g ``[0,2,3,4]``, into a sysfs-style ranges string, e.g. ``"0,2-4"``"""
values = sorted(values)
range_groups = []
for _, g in groupby(enumerate(values), lambda i_x: i_x[0] - i_x[1]):
range_groups.append(list(map(itemgetter(1), g)))