Beispiel #1
0
def parse_lut_file(file_name):
    """Parse the file specified by its name `file_name` for a LUT and
    return the list of parsed values."""

    input = open(file_name, "r")

    line = input.readline()
    n_color = check_lut_first_line(line, file_name)

    lut = []
    for line in input.readlines():
        entr = line.split()
        if len(entr) != 4:
            errmsg="Error: insufficient or too much data in line "\
                    "-- \"%s\""%(entr)
            raise IOError(errmsg)

        tmp = []
        for color in entr:
            try:
                tmp.append(float(color))
            except:
                raise IOError(
                    "Unknown entry '%s'in lookup table input."%color
                )
        lut.append(tmp)

    return lut
Beispiel #2
0
def parse_lut_file(file_name):
    """Parse the file specified by its name `file_name` for a LUT and
    return the list of parsed values."""

    input = open(file_name, "r")

    line = input.readline()
    n_color = check_lut_first_line(line, file_name)

    lut = []
    for line in input.readlines():
        entr = line.split()
        if len(entr) != 4:
            errmsg="Error: insufficient or too much data in line "\
                    "-- \"%s\""%(entr)
            raise IOError, errmsg

        tmp = []
        for color in entr:
            try:
                tmp.append(float(color))
            except:
                raise IOError, \
                      "Unknown entry '%s'in lookup table input."%color
        lut.append(tmp)

    return lut