def parse_list(spec):
    """Convert a string specification like 00-04,07,09-12 into a list [0,1,2,3,4,7,9,10,11,12]

    Args:
        spec (str): string specification

    Returns:
        List[int]

    Example:
        >>> parse_list("00-04,07,09-12")
        [0, 1, 2, 3, 4, 7, 9, 10, 11, 12]
        >>> parse_list("05-04")
        Traceback (most recent call last):
            ...
        ValueError: In specification 05-04, end should not be smaller than begin
    """
    ret_list = []
    for spec_part in spec.split(","):
        if "-" in spec_part:
            begin, end = spec_part.split("-")
            if end < begin:
                raise ValueError(
                    "In specification %s, end should not be smaller than begin" % spec_part)
            ret_list += range(int(begin), int(end) + 1)
        else:
            ret_list += [int(spec_part)]

    return ret_list