def _parse_range_value(range_value):
 end = None
 if range_value.startswith('-'):
  start = int(range_value)
  if (start == 0):
   raise ValueError('-0 is not a valid range.')
 else:
  split_range = range_value.split('-', 1)
  start = int(split_range[0])
  if ((len(split_range) > 1) and split_range[1].strip()):
   end = int(split_range[1])
   if (start > end):
    raise ValueError('start must be <= end.')
 return (start, end)

def _parse_range_value ( range_value ) : end = None if range_value . startswith ( '-' ) : start = int ( range_value ) if ( start == 0 ) : raise ValueError ( '-0 is not a valid range.' ) else : split_range = range_value . split ( '-' , 1 ) start = int ( split_range [ 0 ] ) if ( ( len ( split_range ) > 1 ) and split_range [ 1 ] . strip ( ) ) : end = int ( split_range [ 1 ] ) if ( start > end ) : raise ValueError ( 'start must be <= end.' ) return ( start , end )
parses a single range value from a range header .