zabgrab.ui.selection¶
Parsing of multiple-choice answers such as 1,3,5-8 or all.
Functions
|
Parse a selection of 1-based option numbers into 0-based indices. |
- zabgrab.ui.selection.parse_selection(text, count)[source]¶
Parse a selection of 1-based option numbers into 0-based indices.
Accepts comma-separated numbers and inclusive ranges (
1,3,5-8), orall. Indices are returned in the order given, without duplicates.- Parameters:
- Returns:
list of int – The indices of the options chosen.
- Raises:
ValueError – With a message suitable for showing to the user.
- Return type:
Examples
>>> parse_selection("3,1-2,2", 5) [2, 0, 1]