from_range_strings

igwn_segments.utils.from_range_strings(ranges, boundtype=<class 'int'>)

Parse a list of ranges expressed as strings in the form “value” or “first:last” into an equivalent igwn_segments.segmentlist. In the latter case, an empty string for “first” and(or) “last” indicates a (semi)infinite range. A typical use for this function is in parsing command line options or entries in configuration files.

NOTE: the output is a segmentlist as described by the strings; if the segments in the input file are not coalesced or out of order, then thusly shall be the output of this function. It is recommended that this function’s output be coalesced before use.

Example:

>>> text = "0:10,35,100:"
>>> from_range_strings(text.split(","))
[segment(0, 10), segment(35, 35), segment(100, infinity)]