def extract_intervals(text, repeat=False, sort=True):
result = []<EOL>for value in text.split("<STR_LIT:U+002C>"):<EOL><INDENT>value = value.strip()<EOL>if "<STR_LIT:->" in value:<EOL><INDENT>start_value, end_value = value.split("<STR_LIT:->")<EOL>start_value = int(start_value.strip())<EOL>end_value = int(end_value.strip())<EOL>result.extend(range(start_value, end_value + <NUM_LIT:1>))<EOL><DEDENT>else:<EOL><INDENT>result.append(int(value.strip()))<EOL><DEDENT><DEDENT>if not repeat:<EOL><INDENT>result = list(set(result))<EOL><DEDENT>if sort:<EOL><INDENT>result.sort()<EOL><DEDENT>return result<EOL>
>>> extract_intervals("1,2,3")
[1, 2, 3]
>>> extract_intervals("1,2,5-10")
[1, 2, 5, 6, 7, 8, 9, 10]
>>> extract_intervals("1,2,5-10,3")
[1, 2, 3, 5, 6, 7, 8, 9, 10]
>>> extract_intervals("1,2,5-10,6,7")
[1, 2, 5, 6, 7, 8, 9, 10]