code: def _parse_scale(scale_exp):
      
  
      m = re.search("(\w+?)\{(.*?)\}", scale_exp)
      if m is None:
          raise InvalidFormat('Unable to parse the given time period.')
      scale = m.group(1)
      range = m.group(2)
  
      if scale not in SCALES:
          raise InvalidFormat('%s is not a valid scale.' % scale)
  
      ranges = re.split("\s", range)
  
      return scale, ranges
docs: Parses a scale expression and returns the scale, and a list of ranges.