<s> """<STR_LIT>""" <EOL> __version__ = "<STR_LIT>" <EOL> import os <EOL> from PyOpenColorIO import ( <EOL> Config , ColorSpace , FileTransform , GroupTransform , <EOL> ) <EOL> from PyOpenColorIO . Constants import ( <EOL> INTERP_LINEAR , <EOL> COLORSPACE_DIR_TO_REFERENCE , <EOL> TRANSFORM_DIR_FORWARD , TRANSFORM_DIR_INVERSE , <EOL> ) <EOL> OCIO_1D_LUTS_FORMATS = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> OCIO_3D_LUTS_FORMATS = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> OCIO_LUTS_FORMATS = sorted ( OCIO_1D_LUTS_FORMATS + <EOL> list ( set ( OCIO_3D_LUTS_FORMATS ) - <EOL> set ( OCIO_1D_LUTS_FORMATS ) ) ) <EOL> def create_ocio_processor ( lutfiles , interpolation = INTERP_LINEAR , inverse = False , <EOL> prelutfile = None , postlutfile = None ) : <EOL> """<STR_LIT>""" <EOL> if inverse : <EOL> direction = TRANSFORM_DIR_INVERSE <EOL> else : <EOL> direction = TRANSFORM_DIR_FORWARD <EOL> config = Config ( ) <EOL> colorspace = ColorSpace ( name = '<STR_LIT>' ) <EOL> group = GroupTransform ( ) <EOL> if prelutfile : <EOL> prelut = FileTransform ( prelutfile , interpolation = interpolation ) <EOL> group . push_back ( prelut ) <EOL> if not isinstance ( lutfiles , ( list , tuple ) ) : <EOL> lutfiles = [ lutfiles ] <EOL> for lutfile in lutfiles : <EOL> main_lut = FileTransform ( lutfile , interpolation = interpolation , <EOL> direction = direction ) <EOL> group . push_back ( main_lut ) <EOL> if postlutfile : <EOL> postlut = FileTransform ( postlutfile , interpolation = interpolation ) <EOL> group . push_back ( postlut ) <EOL> colorspace . setTransform ( group , COLORSPACE_DIR_TO_REFERENCE ) <EOL> config . addColorSpace ( colorspace ) <EOL> colorspace = ColorSpace ( name = '<STR_LIT>' ) <EOL> config . addColorSpace ( colorspace ) <EOL> try : <EOL> return config . getProcessor ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except Exception , e : <EOL> if "<STR_LIT>" in str ( e ) : <EOL> return create_ocio_processor ( lutfiles , interpolation = INTERP_LINEAR , <EOL> inverse = inverse , <EOL> prelutfile = prelutfile , <EOL> postlutfile = postlutfile ) <EOL> raise <EOL> def is_3d_lut ( processor , lutfile ) : <EOL> """<STR_LIT>""" <EOL> fileext = os . path . splitext ( lutfile ) [ <NUM_LIT:1> ] <EOL> return processor . hasChannelCrosstalk ( ) or fileext == '<STR_LIT>' </s>
