les_iterables.parsing module¶
Summary¶
Functions:
expand_numbered_list |
Expands a string containing numbered items into a list of integers. |
range_from_text |
A range of integers from a textual description. |
Reference¶
-
les_iterables.parsing.
range_from_text
(text_range: str, separator='-') → range[source]¶ A range of integers from a textual description.
Parameters: text_range – A string of the form “<first>-<last>” such as “7-10” describing the inclusive ends of a range of integers. Returns: A range object. Raises: ValueError
– If the string could not be parsed as an ascending range of at least one item.
-
les_iterables.parsing.
expand_numbered_list
(text, *, separator=', ', range_separator='-')[source]¶ Expands a string containing numbered items into a list of integers.
e.g. “1, 2, 5, 7-10, 15, 20-25” -> [1, 2, 5, 7, 8, 9, 10, 15, 20, 21, 22, 23, 24, 25]
Parameters: - text – A string containing separated integers and ascending integer ranges.
- separator – The item separator. Defaults to “,”.
- range_separator – The separator between the beginning and end of a range. Defaults to “-”
Yields: An iterable series of integers.
Raises: ValueError
– If the list could not be parsed.