def create_ocio_processor(lutfiles, interpolation=INTERP_LINEAR, inverse=False,
                          prelutfile=None, postlutfile=None):
    """Create an OpenColorIO processor for lutfile

    Args:
        lutfiles (str or [str]): path to a LUT or list of LUT paths

        interpolation (int): can be INTERP_NEAREST, INTERP_LINEAR or
        INTERP_TETRAHEDRAL (only for 3D LUT)

        inverse (bool): get an inverse direction processor

    Kwargs:
        prelutfile (str): path to a pre LUT

        postlutfile (str): path to a post LUT

    Returns:
        PyOpenColorIO.config.Processor.

    """
    if inverse:
        direction = TRANSFORM_DIR_INVERSE
    else:
        direction = TRANSFORM_DIR_FORWARD
    config = Config()
    # In colorspace (LUT)
    colorspace = ColorSpace(name='RawInput')
    group = GroupTransform()
    # Prelut
    if prelutfile:
        prelut = FileTransform(prelutfile, interpolation=interpolation)
        group.push_back(prelut)
    # Mainlut
    if not isinstance(lutfiles, (list, tuple)):
        lutfiles = [lutfiles]
    for lutfile in lutfiles:
        main_lut = FileTransform(lutfile, interpolation=interpolation,
                                 direction=direction)
        group.push_back(main_lut)
    # Postlut
    if postlutfile:
        postlut = FileTransform(postlutfile, interpolation=interpolation)
        group.push_back(postlut)
    colorspace.setTransform(group, COLORSPACE_DIR_TO_REFERENCE)
    config.addColorSpace(colorspace)
    # Out colorspace
    colorspace = ColorSpace(name='ProcessedOutput')
    config.addColorSpace(colorspace)
    # Create a processor corresponding to the LUT transformation
    try:
        return config.getProcessor('RawInput', 'ProcessedOutput')
    except Exception, e:
        # tetrahedral interpolation is only allowed with 3D LUT
        # TODO set interpo mode by LUT
        if "tetrahedral interpolation is not allowed" in str(e):
            return create_ocio_processor(lutfiles, interpolation=INTERP_LINEAR,
                                         inverse=inverse,
                                         prelutfile=prelutfile,
                                         postlutfile=postlutfile)
        raise
dataset/ETHPy150Open mikrosimage/ColorPipe-tools/utils/ocio_helper.py/create_ocio_processor/original