def _parse_request_range(range_header):
 (unit, _, value) = range_header.partition('=')
 (unit, value) = (unit.strip(), value.strip())
 if (unit != 'bytes'):
  return None
 (start_b, _, end_b) = value.partition('-')
 try:
  start = _int_or_none(start_b)
  end = _int_or_none(end_b)
 except ValueError:
  return None
 if (end is not None):
  if (start is None):
   if (end != 0):
    start = (- end)
    end = None
  else:
   end += 1
 return (start, end)

def _parse_request_range ( range_header ) : ( unit , _ , value ) = range_header . partition ( '=' ) ( unit , value ) = ( unit . strip ( ) , value . strip ( ) ) if ( unit != 'bytes' ) : return None ( start_b , _ , end_b ) = value . partition ( '-' ) try : start = _int_or_none ( start_b ) end = _int_or_none ( end_b ) except ValueError : return None if ( end is not None ) : if ( start is None ) : if ( end != 0 ) : start = ( - end ) end = None else : end += 1 return ( start , end )
parses a range header .