def parse_content_range_header(value, on_update=None):
 if (value is None):
  return None
 try:
  (units, rangedef) = (value or '').strip().split(None, 1)
 except ValueError:
  return None
 if ('/' not in rangedef):
  return None
 (rng, length) = rangedef.split('/', 1)
 if (length == '*'):
  length = None
 elif length.isdigit():
  length = int(length)
 else:
  return None
 if (rng == '*'):
  return ContentRange(units, None, None, length, on_update=on_update)
 elif ('-' not in rng):
  return None
 (start, stop) = rng.split('-', 1)
 try:
  start = int(start)
  stop = (int(stop) + 1)
 except ValueError:
  return None
 if is_byte_range_valid(start, stop, length):
  return ContentRange(units, start, stop, length, on_update=on_update)

def parse_content_range_header ( value , on_update = None ) : if ( value is None ) : return None try : ( units , rangedef ) = ( value or '' ) . strip ( ) . split ( None , 1 ) except ValueError : return None if ( '/' not in rangedef ) : return None ( rng , length ) = rangedef . split ( '/' , 1 ) if ( length == '*' ) : length = None elif length . isdigit ( ) : length = int ( length ) else : return None if ( rng == '*' ) : return ContentRange ( units , None , None , length , on_update = on_update ) elif ( '-' not in rng ) : return None ( start , stop ) = rng . split ( '-' , 1 ) try : start = int ( start ) stop = ( int ( stop ) + 1 ) except ValueError : return None if is_byte_range_valid ( start , stop , length ) : return ContentRange ( units , start , stop , length , on_update = on_update )
parses a range header into a :class:~werkzeug .