You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
451 B
Python
18 lines
451 B
Python
class FilterModule:
|
|
def filters(self):
|
|
return {
|
|
"aruba_ints": aruba_ints,
|
|
}
|
|
|
|
|
|
def aruba_ints(seq, sep=",", hyphen="-"):
|
|
ranges = []
|
|
for value in sorted(seq):
|
|
if not ranges or ranges[-1][1] + 1 != value:
|
|
ranges.append((value, value))
|
|
else:
|
|
ranges[-1] = (ranges[-1][0], value)
|
|
return sep.join(
|
|
(f"{a}" if a == b else f"{a}{hyphen}{b}" for a, b in ranges)
|
|
)
|