<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _parse_scale(scale_exp):
 """Parses a scale expression and returns the scale, and a list of ranges."""


    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