import re


def parse_shift_spec(spans : str = ""):
    """
    Parse a shift specification line of the form

    '09:00-12:00, 15:00-18:00, ...'
    """
    if spans.replace(" ", "") == "":
        return []

    p = re.compile("^(\d\d):(\d\d)-(\d\d):(\d\d)$")
    def parse_interval(s):
        m = p.match(s.replace(" ", ""))
        if m is not None:
            t0 = int(m.group(1))*60 + int(m.group(2))
            t1 = int(m.group(3))*60 + int(m.group(4))
            return [t0, t1]
        else:
            raise Exception("invalid shift specification {}".format(s))

    return [parse_interval(s) for s in spans.split(",")]