first commit
This commit is contained in:
commit
f2db1af089
9 changed files with 270 additions and 0 deletions
14
utils.py
Normal file
14
utils.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
def parse_selection(inp, max_index):
|
||||
if inp.strip().lower() == "all":
|
||||
return list(range(max_index))
|
||||
|
||||
result = set()
|
||||
for part in inp.split(","):
|
||||
part = part.strip()
|
||||
if "-" in part:
|
||||
a, b = part.split("-")
|
||||
result.update(range(int(a) - 1, int(b)))
|
||||
else:
|
||||
result.add(int(part) - 1)
|
||||
|
||||
return sorted(i for i in result if 0 <= i < max_index)
|
||||
Loading…
Add table
Add a link
Reference in a new issue