def block_to_list(block):
    """ Convert a range block into a numeric list
        input "1-3,17,19-20"
        output=[1,2,3,17,19,20]
    """
    block += ','
    result = []
    val = val1 = ''
    in_range = False
    for letter in block:
        if letter in [',', '-']:
            if in_range:
                val2 = val
                val2_len = len(val2)
                # result+=range(int(val1),int(val2)+1)
                for value in range(int(val1), int(val2) + 1):
                    if val1.startswith('0'):
                        result.append(str(value).zfill(val2_len))
                    else:
                        result.append(str(value))
                val = ''
                val1 = None
                in_range = False
            else:
                val1 = val
                val1_len = len(val1)
                val = ''
            if letter == ',':
                if val1 is not None:
                    result.append(val1.zfill(val1_len))  # pragma: no cover
            else:
                in_range = True
        else:
            val += letter
    return result
dataset/ETHPy150Open dwighthubbard/hostlists/hostlists/plugins/range.py/block_to_list/original