@classmethod<EOL><INDENT>def parse_byteranges(cls, environ):<DEDENT>
r = []<EOL>s = environ.get(cls.header_range, '<STR_LIT>').replace('<STR_LIT:U+0020>','<STR_LIT>').lower()<EOL>if s:<EOL><INDENT>l = s.split('<STR_LIT:=>')<EOL>if len(l) == <NUM_LIT:2>:<EOL><INDENT>unit, vals = tuple(l)<EOL>if unit == '<STR_LIT>' and vals:<EOL><INDENT>gen_rng = ( tuple(rng.split('<STR_LIT:->')) for rng in vals.split('<STR_LIT:U+002C>') if '<STR_LIT:->' in rng )<EOL>for start, end in gen_rng:<EOL><INDENT>if start or end:<EOL><INDENT>r.append( (int(start) if start else None, int(end) if end else None) )<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return r<EOL>
Outputs a list of tuples with ranges or the empty list
According to the rfc, start or end values can be omitted