PageRenderTime 122ms CodeModel.GetById 12ms app.highlight 103ms RepoModel.GetById 1ms app.codeStats 0ms

/src/pyglue/PyConfig.cpp

http://github.com/imageworks/OpenColorIO
C++ | 1044 lines | 909 code | 94 blank | 41 comment | 59 complexity | 4eba1f8a8dac75c10e5741d0e93f6688 MD5 | raw file
   1/*
   2Copyright (c) 2003-2010 Sony Pictures Imageworks Inc., et al.
   3All Rights Reserved.
   4
   5Redistribution and use in source and binary forms, with or without
   6modification, are permitted provided that the following conditions are
   7met:
   8* Redistributions of source code must retain the above copyright
   9  notice, this list of conditions and the following disclaimer.
  10* Redistributions in binary form must reproduce the above copyright
  11  notice, this list of conditions and the following disclaimer in the
  12  documentation and/or other materials provided with the distribution.
  13* Neither the name of Sony Pictures Imageworks nor the names of its
  14  contributors may be used to endorse or promote products derived from
  15  this software without specific prior written permission.
  16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  17"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  18LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  19A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  20OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  21SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  22LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  26OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27*/
  28
  29#include <Python.h>
  30#include <sstream>
  31#include <OpenColorIO/OpenColorIO.h>
  32
  33#include "PyUtil.h"
  34#include "PyDoc.h"
  35
  36OCIO_NAMESPACE_ENTER
  37{
  38    
  39    PyObject * BuildConstPyConfig(ConstConfigRcPtr config)
  40    {
  41        return BuildConstPyOCIO<PyOCIO_Config, ConfigRcPtr,
  42            ConstConfigRcPtr>(config, PyOCIO_ConfigType);
  43    }
  44    
  45    PyObject * BuildEditablePyConfig(ConfigRcPtr config)
  46    {
  47        return BuildEditablePyOCIO<PyOCIO_Config, ConfigRcPtr,
  48            ConstConfigRcPtr>(config, PyOCIO_ConfigType);
  49    }
  50    
  51    bool IsPyConfig(PyObject * pyobject)
  52    {
  53        return IsPyOCIOType(pyobject, PyOCIO_ConfigType);
  54    }
  55    
  56    bool IsPyConfigEditable(PyObject * pyobject)
  57    {
  58        return IsPyEditable<PyOCIO_Config>(pyobject, PyOCIO_ConfigType);
  59    }
  60    
  61    ConstConfigRcPtr GetConstConfig(PyObject * pyobject, bool allowCast)
  62    {
  63        return GetConstPyOCIO<PyOCIO_Config, ConstConfigRcPtr>(pyobject,
  64            PyOCIO_ConfigType, allowCast);
  65    }
  66    
  67    ConfigRcPtr GetEditableConfig(PyObject * pyobject)
  68    {
  69        return GetEditablePyOCIO<PyOCIO_Config, ConfigRcPtr>(pyobject,
  70            PyOCIO_ConfigType);
  71    }
  72    
  73    namespace
  74    {
  75        
  76        ///////////////////////////////////////////////////////////////////////
  77        ///
  78        
  79        PyObject * PyOCIO_Config_CreateFromEnv(PyObject * cls);
  80        PyObject * PyOCIO_Config_CreateFromFile(PyObject * cls, PyObject * args);
  81        PyObject * PyOCIO_Config_CreateFromStream(PyObject * cls, PyObject * args);
  82        int PyOCIO_Config_init(PyOCIO_Config * self, PyObject * args, PyObject * kwds);
  83        void PyOCIO_Config_delete(PyOCIO_Config * self, PyObject * args);
  84        PyObject * PyOCIO_Config_isEditable(PyObject * self);
  85        PyObject * PyOCIO_Config_createEditableCopy(PyObject * self);
  86        PyObject * PyOCIO_Config_sanityCheck(PyObject * self);
  87        PyObject * PyOCIO_Config_getDescription(PyObject * self);
  88        PyObject * PyOCIO_Config_setDescription(PyObject * self, PyObject * args);
  89        PyObject * PyOCIO_Config_serialize(PyObject * self);
  90        PyObject * PyOCIO_Config_getCacheID(PyObject * self, PyObject * args);
  91        PyObject * PyOCIO_Config_getCurrentContext(PyObject * self);
  92        PyObject * PyOCIO_Config_addEnvironmentVar(PyObject * self, PyObject * args);
  93        PyObject * PyOCIO_Config_getNumEnvironmentVars(PyObject * self);
  94        PyObject * PyOCIO_Config_getEnvironmentVarNameByIndex(PyObject * self, PyObject * args);
  95        PyObject * PyOCIO_Config_getEnvironmentVarDefault(PyObject * self, PyObject * args);
  96        PyObject * PyOCIO_Config_getEnvironmentVarDefaults(PyObject * self);
  97        PyObject * PyOCIO_Config_clearEnvironmentVars(PyObject * self);
  98        PyObject * PyOCIO_Config_getSearchPath(PyObject * self);
  99        PyObject * PyOCIO_Config_setSearchPath(PyObject * self, PyObject * args);
 100        PyObject * PyOCIO_Config_getWorkingDir(PyObject * self);
 101        PyObject * PyOCIO_Config_setWorkingDir(PyObject * self,  PyObject * args);
 102        PyObject * PyOCIO_Config_getNumColorSpaces(PyObject * self);
 103        PyObject * PyOCIO_Config_getColorSpaceNameByIndex(PyObject * self,  PyObject * args);
 104        PyObject * PyOCIO_Config_getColorSpaces(PyObject * self); // py interface only
 105        PyObject * PyOCIO_Config_getColorSpace(PyObject * self, PyObject * args);
 106        PyObject * PyOCIO_Config_getIndexForColorSpace(PyObject * self,  PyObject * args);
 107        PyObject * PyOCIO_Config_addColorSpace(PyObject * self, PyObject * args);
 108        PyObject * PyOCIO_Config_clearColorSpaces(PyObject * self);
 109        PyObject * PyOCIO_Config_parseColorSpaceFromString(PyObject * self, PyObject * args);
 110        PyObject * PyOCIO_Config_isStrictParsingEnabled(PyObject * self);
 111        PyObject * PyOCIO_Config_setStrictParsingEnabled(PyObject * self, PyObject * args);
 112        PyObject * PyOCIO_Config_setRole(PyObject * self, PyObject * args);
 113        PyObject * PyOCIO_Config_getNumRoles(PyObject * self);
 114        PyObject * PyOCIO_Config_hasRole(PyObject * self, PyObject * args);
 115        PyObject * PyOCIO_Config_getRoleName(PyObject * self, PyObject * args);
 116        PyObject * PyOCIO_Config_getDefaultDisplay(PyObject * self);
 117        PyObject * PyOCIO_Config_getNumDisplays(PyObject * self);
 118        PyObject * PyOCIO_Config_getDisplay(PyObject * self, PyObject * args);
 119        PyObject * PyOCIO_Config_getDisplays(PyObject * self);
 120        PyObject * PyOCIO_Config_getDefaultView(PyObject * self, PyObject * args);
 121        PyObject * PyOCIO_Config_getNumViews(PyObject * self, PyObject * args);
 122        PyObject * PyOCIO_Config_getView(PyObject * self, PyObject * args);
 123        PyObject * PyOCIO_Config_getViews(PyObject * self, PyObject * args);
 124        PyObject * PyOCIO_Config_getDisplayColorSpaceName(PyObject * self, PyObject * args);
 125        PyObject * PyOCIO_Config_getDisplayLooks(PyObject * self, PyObject * args);
 126        PyObject * PyOCIO_Config_addDisplay(PyObject * self, PyObject * args, PyObject * kwargs);
 127        PyObject * PyOCIO_Config_clearDisplays(PyObject * self);
 128        PyObject * PyOCIO_Config_setActiveDisplays(PyObject * self, PyObject * args);
 129        PyObject * PyOCIO_Config_getActiveDisplays(PyObject * self);
 130        PyObject * PyOCIO_Config_setActiveViews(PyObject * self, PyObject * args);
 131        PyObject * PyOCIO_Config_getActiveViews(PyObject * self);
 132        PyObject * PyOCIO_Config_getDefaultLumaCoefs(PyObject * self);
 133        PyObject * PyOCIO_Config_setDefaultLumaCoefs(PyObject * self, PyObject * args);
 134        PyObject * PyOCIO_Config_getLook( PyObject * self, PyObject * args);
 135        PyObject * PyOCIO_Config_getNumLooks(PyObject * self);
 136        PyObject * PyOCIO_Config_getLookNameByIndex(PyObject * self, PyObject * args);        
 137        PyObject * PyOCIO_Config_getLooks(PyObject * self);
 138        PyObject * PyOCIO_Config_addLook(PyObject * self, PyObject * args);
 139        PyObject * PyOCIO_Config_clearLooks(PyObject * self);
 140        PyObject * PyOCIO_Config_getProcessor(PyObject * self, PyObject * args, PyObject * kwargs);
 141        
 142        ///////////////////////////////////////////////////////////////////////
 143        ///
 144        
 145        PyMethodDef PyOCIO_Config_methods[] = {
 146            { "CreateFromEnv",
 147            (PyCFunction) PyOCIO_Config_CreateFromEnv, METH_NOARGS | METH_CLASS, CONFIG_CREATEFROMENV__DOC__ },
 148            { "CreateFromFile",
 149            PyOCIO_Config_CreateFromFile, METH_VARARGS | METH_CLASS, CONFIG_CREATEFROMFILE__DOC__ },
 150            { "CreateFromStream",
 151            PyOCIO_Config_CreateFromStream, METH_VARARGS | METH_CLASS, CONFIG_CREATEFROMSTREAM__DOC__ },
 152            { "isEditable",
 153            (PyCFunction) PyOCIO_Config_isEditable, METH_NOARGS, CONFIG_ISEDITABLE__DOC__ },
 154            { "createEditableCopy",
 155            (PyCFunction) PyOCIO_Config_createEditableCopy, METH_NOARGS, CONFIG_CREATEEDITABLECOPY__DOC__ },
 156            { "sanityCheck",
 157            (PyCFunction) PyOCIO_Config_sanityCheck, METH_NOARGS, CONFIG_SANITYCHECK__DOC__ },
 158            { "getDescription",
 159            (PyCFunction) PyOCIO_Config_getDescription, METH_NOARGS, CONFIG_GETDESCRIPTION__DOC__ },
 160            { "setDescription",
 161            PyOCIO_Config_setDescription, METH_VARARGS, CONFIG_SETDESCRIPTION__DOC__ },
 162            { "serialize",
 163            (PyCFunction) PyOCIO_Config_serialize, METH_NOARGS, CONFIG_SERIALIZE__DOC__ },
 164            { "getCacheID",
 165            PyOCIO_Config_getCacheID, METH_VARARGS, CONFIG_GETCACHEID__DOC__ },
 166            { "getCurrentContext",
 167            (PyCFunction) PyOCIO_Config_getCurrentContext, METH_NOARGS, CONFIG_GETCURRENTCONTEXT__DOC__ },
 168            { "addEnvironmentVar",
 169            PyOCIO_Config_addEnvironmentVar, METH_VARARGS, CONFIG_ADDENVIRONMENTVAR__DOC__ },
 170            { "getNumEnvironmentVars",
 171            (PyCFunction)PyOCIO_Config_getNumEnvironmentVars, METH_NOARGS, CONFIG_GETNUMENVIRONMENTVARS__DOC__ },
 172            { "getEnvironmentVarNameByIndex",
 173            PyOCIO_Config_getEnvironmentVarNameByIndex, METH_VARARGS, CONFIG_GETENVIRONMENTVARNAMEBYINDEX__DOC__ },
 174            { "getEnvironmentVarDefault",
 175            PyOCIO_Config_getEnvironmentVarDefault, METH_VARARGS, CONFIG_GETENVIRONMENTVARDEFAULT__DOC__ },
 176            { "getEnvironmentVarDefaults",
 177            (PyCFunction)PyOCIO_Config_getEnvironmentVarDefaults, METH_NOARGS, CONFIG_GETENVIRONMENTVARDEFAULTS__DOC__ },
 178            { "clearEnvironmentVars",
 179            (PyCFunction)PyOCIO_Config_clearEnvironmentVars, METH_NOARGS, CONFIG_CLEARENVIRONMENTVARS__DOC__ },
 180            { "getSearchPath",
 181            (PyCFunction) PyOCIO_Config_getSearchPath, METH_NOARGS, CONFIG_GETSEARCHPATH__DOC__ },
 182            { "setSearchPath",
 183            PyOCIO_Config_setSearchPath, METH_VARARGS, CONFIG_SETSEARCHPATH__DOC__ },
 184            { "getWorkingDir",
 185            (PyCFunction) PyOCIO_Config_getWorkingDir, METH_NOARGS, CONFIG_GETWORKINGDIR__DOC__ },
 186            { "setWorkingDir",
 187            PyOCIO_Config_setWorkingDir, METH_VARARGS, CONFIG_SETWORKINGDIR__DOC__ },
 188            { "getNumColorSpaces",
 189            (PyCFunction) PyOCIO_Config_getNumColorSpaces, METH_VARARGS, CONFIG_GETNUMCOLORSPACES__DOC__ },
 190            { "getColorSpaceNameByIndex",
 191            PyOCIO_Config_getColorSpaceNameByIndex, METH_VARARGS, CONFIG_GETCOLORSPACENAMEBYINDEX__DOC__ },
 192            { "getColorSpaces",
 193            (PyCFunction) PyOCIO_Config_getColorSpaces, METH_NOARGS, CONFIG_GETCOLORSPACES__DOC__ },
 194            { "getColorSpace",
 195            PyOCIO_Config_getColorSpace, METH_VARARGS, CONFIG_GETCOLORSPACE__DOC__ },
 196            { "getIndexForColorSpace",
 197            PyOCIO_Config_getIndexForColorSpace, METH_VARARGS, CONFIG_GETINDEXFORCOLORSPACE__DOC__ },
 198            { "addColorSpace",
 199            PyOCIO_Config_addColorSpace, METH_VARARGS, CONFIG_ADDCOLORSPACE__DOC__ },
 200            { "clearColorSpaces",
 201            (PyCFunction) PyOCIO_Config_clearColorSpaces, METH_NOARGS, CONFIG_CLEARCOLORSPACES__DOC__ },
 202            { "parseColorSpaceFromString",
 203            PyOCIO_Config_parseColorSpaceFromString, METH_VARARGS, CONFIG_PARSECOLORSPACEFROMSTRING__DOC__ },
 204            { "isStrictParsingEnabled",
 205            (PyCFunction) PyOCIO_Config_isStrictParsingEnabled, METH_NOARGS, CONFIG_ISSTRICTPARSINGENABLED__DOC__ },
 206            { "setStrictParsingEnabled",
 207            PyOCIO_Config_setStrictParsingEnabled, METH_VARARGS, CONFIG_SETSTRICTPARSINGENABLED__DOC__ },
 208            { "setRole",
 209            PyOCIO_Config_setRole, METH_VARARGS, CONFIG_SETROLE__DOC__ },
 210            { "getNumRoles",
 211            (PyCFunction) PyOCIO_Config_getNumRoles, METH_NOARGS, CONFIG_GETNUMROLES__DOC__ },
 212            { "hasRole",
 213            PyOCIO_Config_hasRole, METH_VARARGS, CONFIG_HASROLE__DOC__ },
 214            { "getRoleName",
 215            PyOCIO_Config_getRoleName, METH_VARARGS, CONFIG_GETROLENAME__DOC__ },
 216            { "getDefaultDisplay",
 217            (PyCFunction) PyOCIO_Config_getDefaultDisplay, METH_NOARGS, CONFIG_GETDEFAULTDISPLAY__DOC__ },
 218            { "getNumDisplays",
 219            (PyCFunction) PyOCIO_Config_getNumDisplays, METH_NOARGS, CONFIG_GETNUMDISPLAYS__DOC__ },
 220            { "getDisplay",
 221            PyOCIO_Config_getDisplay, METH_VARARGS, CONFIG_GETDISPLAY__DOC__ },
 222            { "getDisplays",
 223            (PyCFunction) PyOCIO_Config_getDisplays, METH_NOARGS, CONFIG_GETDISPLAYS__DOC__ },
 224            { "getDefaultView",
 225            PyOCIO_Config_getDefaultView, METH_VARARGS, CONFIG_GETDEFAULTVIEW__DOC__ },
 226            { "getNumViews",
 227            PyOCIO_Config_getNumViews, METH_VARARGS, CONFIG_GETNUMVIEWS__DOC__ },
 228            { "getView",
 229            PyOCIO_Config_getView, METH_VARARGS, CONFIG_GETVIEW__DOC__ },
 230            { "getViews",
 231            PyOCIO_Config_getViews, METH_VARARGS, CONFIG_GETVIEWS__DOC__ },
 232            { "getDisplayColorSpaceName",
 233            PyOCIO_Config_getDisplayColorSpaceName, METH_VARARGS, CONFIG_GETDISPLAYCOLORSPACENAME__DOC__ },
 234            { "getDisplayLooks",
 235            PyOCIO_Config_getDisplayLooks, METH_VARARGS, CONFIG_GETDISPLAYLOOKS__DOC__ },
 236            { "addDisplay",
 237            (PyCFunction) PyOCIO_Config_addDisplay, METH_VARARGS|METH_KEYWORDS, CONFIG_ADDDISPLAY__DOC__ },
 238            { "clearDisplays",
 239            (PyCFunction) PyOCIO_Config_clearDisplays, METH_NOARGS, CONFIG_CLEARDISPLAYS__DOC__ },
 240            { "setActiveDisplays",
 241            PyOCIO_Config_setActiveDisplays, METH_VARARGS, CONFIG_SETACTIVEDISPLAYS__DOC__ },
 242            { "getActiveDisplays",
 243            (PyCFunction) PyOCIO_Config_getActiveDisplays, METH_NOARGS, CONFIG_GETACTIVEDISPLAYS__DOC__ },
 244            { "setActiveViews",
 245            PyOCIO_Config_setActiveViews, METH_VARARGS, CONFIG_SETACTIVEVIEWS__DOC__ },
 246            { "getActiveViews",
 247            (PyCFunction) PyOCIO_Config_getActiveViews, METH_NOARGS, CONFIG_GETACTIVEVIEWS__DOC__ },
 248            { "getDefaultLumaCoefs",
 249            (PyCFunction) PyOCIO_Config_getDefaultLumaCoefs, METH_NOARGS, CONFIG_GETDEFAULTLUMACOEFS__DOC__ },
 250            { "setDefaultLumaCoefs",
 251            PyOCIO_Config_setDefaultLumaCoefs, METH_VARARGS, CONFIG_SETDEFAULTLUMACOEFS__DOC__ },
 252            { "getLook",
 253            PyOCIO_Config_getLook, METH_VARARGS, CONFIG_GETLOOK__DOC__ },
 254            { "getNumLooks",
 255            (PyCFunction) PyOCIO_Config_getNumLooks, METH_NOARGS, CONFIG_GETNUMLOOKS__DOC__ },
 256            { "getLookNameByIndex",
 257            PyOCIO_Config_getLookNameByIndex, METH_VARARGS, CONFIG_GETLOOKNAMEBYINDEX__DOC__ },
 258            { "getLooks",
 259            (PyCFunction) PyOCIO_Config_getLooks, METH_NOARGS, CONFIG_GETLOOKS__DOC__ },
 260            { "addLook",
 261            PyOCIO_Config_addLook, METH_VARARGS, CONFIG_ADDLOOK__DOC__ },
 262            { "clearLook", // THIS SHOULD BE REMOVED IN THE NEXT BINARY INCOMPATIBLE VERSION
 263            (PyCFunction) PyOCIO_Config_clearLooks, METH_NOARGS, CONFIG_CLEARLOOKS__DOC__ },
 264            { "clearLooks",
 265            (PyCFunction) PyOCIO_Config_clearLooks, METH_NOARGS, CONFIG_CLEARLOOKS__DOC__ },
 266            { "getProcessor",
 267            (PyCFunction) PyOCIO_Config_getProcessor, METH_VARARGS|METH_KEYWORDS, CONFIG_GETPROCESSOR__DOC__ },
 268            { NULL, NULL, 0, NULL }
 269        };
 270        
 271    }
 272    
 273    ///////////////////////////////////////////////////////////////////////////
 274    ///
 275    
 276    PyTypeObject PyOCIO_ConfigType = {
 277        PyVarObject_HEAD_INIT(NULL, 0)              //obsize
 278        "OCIO.Config",                              //tp_name
 279        sizeof(PyOCIO_Config),                      //tp_basicsize
 280        0,                                          //tp_itemsize
 281        (destructor)PyOCIO_Config_delete,           //tp_dealloc
 282        0,                                          //tp_print
 283        0,                                          //tp_getattr
 284        0,                                          //tp_setattr
 285        0,                                          //tp_compare
 286        0,                                          //tp_repr
 287        0,                                          //tp_as_number
 288        0,                                          //tp_as_sequence
 289        0,                                          //tp_as_mapping
 290        0,                                          //tp_hash 
 291        0,                                          //tp_call
 292        0,                                          //tp_str
 293        0,                                          //tp_getattro
 294        0,                                          //tp_setattro
 295        0,                                          //tp_as_buffer
 296        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,   //tp_flags
 297        CONFIG__DOC__,                              //tp_doc 
 298        0,                                          //tp_traverse 
 299        0,                                          //tp_clear 
 300        0,                                          //tp_richcompare 
 301        0,                                          //tp_weaklistoffset 
 302        0,                                          //tp_iter 
 303        0,                                          //tp_iternext 
 304        PyOCIO_Config_methods,                      //tp_methods 
 305        0,                                          //tp_members 
 306        0,                                          //tp_getset 
 307        0,                                          //tp_base 
 308        0,                                          //tp_dict 
 309        0,                                          //tp_descr_get 
 310        0,                                          //tp_descr_set 
 311        0,                                          //tp_dictoffset 
 312        (initproc) PyOCIO_Config_init,              //tp_init 
 313        0,                                          //tp_alloc 
 314        0,                                          //tp_new 
 315        0,                                          //tp_free
 316        0,                                          //tp_is_gc
 317    };
 318    
 319    namespace
 320    {
 321        
 322        ///////////////////////////////////////////////////////////////////////
 323        ///
 324        
 325        PyObject * PyOCIO_Config_CreateFromEnv(PyObject * /*self*/)
 326        {
 327            OCIO_PYTRY_ENTER()
 328            return BuildConstPyConfig(Config::CreateFromEnv());
 329            OCIO_PYTRY_EXIT(NULL)
 330        }
 331        
 332        PyObject * PyOCIO_Config_CreateFromFile(PyObject * /*self*/, PyObject * args)
 333        {
 334            OCIO_PYTRY_ENTER()
 335            char* filename = 0;
 336            if (!PyArg_ParseTuple(args,"s:CreateFromFile", &filename)) return NULL;
 337            return BuildConstPyConfig(Config::CreateFromFile(filename));
 338            OCIO_PYTRY_EXIT(NULL)
 339        }
 340        
 341        PyObject * PyOCIO_Config_CreateFromStream(PyObject * /*self*/, PyObject * args)
 342        {
 343            OCIO_PYTRY_ENTER()
 344            char* stream = 0;
 345            if (!PyArg_ParseTuple(args,"s:CreateFromStream", &stream)) return NULL;
 346            std::istringstream is;
 347            is.str(stream);
 348            return BuildConstPyConfig(Config::CreateFromStream(is));
 349            OCIO_PYTRY_EXIT(NULL)
 350        }
 351        
 352        int PyOCIO_Config_init(PyOCIO_Config *self, PyObject * /*args*/, PyObject * /*kwds*/)
 353        {
 354            OCIO_PYTRY_ENTER()
 355            return BuildPyObject<PyOCIO_Config, ConstConfigRcPtr, ConfigRcPtr>(self, Config::Create());
 356            OCIO_PYTRY_EXIT(-1)
 357        }
 358        
 359        void PyOCIO_Config_delete(PyOCIO_Config *self, PyObject * /*args*/)
 360        {
 361            DeletePyObject<PyOCIO_Config>(self);
 362        }
 363        
 364        PyObject * PyOCIO_Config_isEditable(PyObject * self)
 365        {
 366            return PyBool_FromLong(IsPyConfigEditable(self));
 367        }
 368        
 369        PyObject * PyOCIO_Config_createEditableCopy(PyObject * self)
 370        {
 371            OCIO_PYTRY_ENTER()
 372            ConstConfigRcPtr config = GetConstConfig(self, true);
 373            ConfigRcPtr copy = config->createEditableCopy();
 374            return BuildEditablePyConfig(copy);
 375            OCIO_PYTRY_EXIT(NULL)
 376        }
 377        
 378        PyObject * PyOCIO_Config_sanityCheck(PyObject * self)
 379        {
 380            OCIO_PYTRY_ENTER()
 381            ConstConfigRcPtr config = GetConstConfig(self, true);
 382            config->sanityCheck();
 383            Py_RETURN_NONE;
 384            OCIO_PYTRY_EXIT(NULL)
 385        }
 386        
 387        PyObject * PyOCIO_Config_getDescription(PyObject * self)
 388        {
 389            OCIO_PYTRY_ENTER()
 390            ConstConfigRcPtr config = GetConstConfig(self, true);
 391            return PyString_FromString(config->getDescription());
 392            OCIO_PYTRY_EXIT(NULL)
 393        }
 394        
 395        PyObject * PyOCIO_Config_setDescription(PyObject * self, PyObject * args)
 396        {
 397            OCIO_PYTRY_ENTER()
 398            char* desc = 0;
 399            if (!PyArg_ParseTuple(args, "s:setDescription",
 400                &desc)) return NULL;
 401            ConfigRcPtr config = GetEditableConfig(self);
 402            config->setDescription(desc);
 403            Py_RETURN_NONE;
 404            OCIO_PYTRY_EXIT(NULL)
 405        }
 406        
 407        PyObject * PyOCIO_Config_serialize(PyObject * self)
 408        {
 409            OCIO_PYTRY_ENTER()
 410            ConstConfigRcPtr config = GetConstConfig(self, true);
 411            std::ostringstream os;
 412            config->serialize(os);
 413            return PyString_FromString(os.str().c_str());
 414            OCIO_PYTRY_EXIT(NULL)
 415        }
 416        
 417        PyObject * PyOCIO_Config_getCacheID(PyObject * self, PyObject * args)
 418        {
 419            OCIO_PYTRY_ENTER()
 420            PyObject* pycontext = NULL;
 421            if (!PyArg_ParseTuple(args, "|O:getCacheID",
 422                &pycontext)) return NULL;
 423            ConstConfigRcPtr config = GetConstConfig(self, true);
 424            ConstContextRcPtr context;
 425            if(pycontext != NULL) context = GetConstContext(pycontext, true);
 426            else context = config->getCurrentContext();
 427            return PyString_FromString(config->getCacheID(context));
 428            OCIO_PYTRY_EXIT(NULL)
 429        }
 430        
 431        PyObject * PyOCIO_Config_getCurrentContext(PyObject * self)
 432        {
 433            OCIO_PYTRY_ENTER()
 434            ConstConfigRcPtr config = GetConstConfig(self, true);
 435            return BuildConstPyContext(config->getCurrentContext());
 436            OCIO_PYTRY_EXIT(NULL)
 437        }
 438        
 439        PyObject * PyOCIO_Config_addEnvironmentVar(PyObject * self, PyObject * args)
 440        {
 441            OCIO_PYTRY_ENTER()
 442            char* name = 0;
 443            char* value = 0;
 444            if (!PyArg_ParseTuple(args, "ss:addEnvironmentVar",
 445                &name, &value)) return NULL;
 446            ConfigRcPtr config = GetEditableConfig(self);
 447            config->addEnvironmentVar(name, value);
 448            Py_RETURN_NONE;
 449            OCIO_PYTRY_EXIT(NULL)
 450        }
 451        
 452        PyObject * PyOCIO_Config_getNumEnvironmentVars(PyObject * self)
 453        {
 454            OCIO_PYTRY_ENTER()
 455            ConstConfigRcPtr config = GetConstConfig(self, true);
 456            return PyInt_FromLong(config->getNumEnvironmentVars());
 457            OCIO_PYTRY_EXIT(NULL)
 458        }
 459        
 460        PyObject * PyOCIO_Config_getEnvironmentVarNameByIndex(PyObject * self, PyObject * args)
 461        {
 462            OCIO_PYTRY_ENTER()
 463            int index = 0;
 464            if (!PyArg_ParseTuple(args,"i:getEnvironmentVarNameByIndex",
 465                &index)) return NULL;
 466            ConstConfigRcPtr config = GetConstConfig(self, true);
 467            return PyString_FromString(config->getEnvironmentVarNameByIndex(index));
 468            OCIO_PYTRY_EXIT(NULL)
 469        }
 470        
 471        PyObject * PyOCIO_Config_getEnvironmentVarDefault(PyObject * self, PyObject * args)
 472        {
 473            OCIO_PYTRY_ENTER()
 474            char* name = 0;
 475            if (!PyArg_ParseTuple(args, "s:getEnvironmentVarDefault",
 476                &name)) return NULL;
 477            ConstConfigRcPtr config = GetConstConfig(self, true);
 478            return PyString_FromString(config->getEnvironmentVarDefault(name));
 479            OCIO_PYTRY_EXIT(NULL)
 480        }
 481        
 482        PyObject * PyOCIO_Config_getEnvironmentVarDefaults(PyObject * self)
 483        {
 484            OCIO_PYTRY_ENTER()
 485            std::map<std::string, std::string> data;
 486            ConstConfigRcPtr config = GetConstConfig(self, true);
 487            for(int i = 0; i < config->getNumEnvironmentVars(); ++i) {
 488                const char* name = config->getEnvironmentVarNameByIndex(i);
 489                const char* value = config->getEnvironmentVarDefault(name);
 490                data.insert(std::pair<std::string, std::string>(name, value));
 491            }
 492            return CreatePyDictFromStringMap(data);
 493            OCIO_PYTRY_EXIT(NULL)
 494        }
 495        
 496        PyObject * PyOCIO_Config_clearEnvironmentVars(PyObject * self)
 497        {
 498            OCIO_PYTRY_ENTER()
 499            ConfigRcPtr config = GetEditableConfig(self);
 500            config->clearEnvironmentVars();
 501            Py_RETURN_NONE;
 502            OCIO_PYTRY_EXIT(NULL)
 503        }
 504        
 505        PyObject * PyOCIO_Config_getSearchPath(PyObject * self)
 506        {
 507            OCIO_PYTRY_ENTER()
 508            ConstConfigRcPtr config = GetConstConfig(self, true);
 509            return PyString_FromString(config->getSearchPath());
 510            OCIO_PYTRY_EXIT(NULL)
 511        }
 512        
 513        PyObject * PyOCIO_Config_setSearchPath(PyObject * self, PyObject * args)
 514        {
 515            OCIO_PYTRY_ENTER()
 516            char* path = 0;
 517            if (!PyArg_ParseTuple(args, "s:setSearchPath",
 518                &path)) return NULL;
 519            ConfigRcPtr config = GetEditableConfig(self);
 520            config->setSearchPath(path);
 521            Py_RETURN_NONE;
 522            OCIO_PYTRY_EXIT(NULL)
 523        }
 524        
 525        PyObject * PyOCIO_Config_getWorkingDir(PyObject * self)
 526        {
 527            OCIO_PYTRY_ENTER()
 528            ConstConfigRcPtr config = GetConstConfig(self, true);
 529            return PyString_FromString(config->getWorkingDir());
 530            OCIO_PYTRY_EXIT(NULL)
 531        }
 532        
 533        PyObject * PyOCIO_Config_setWorkingDir(PyObject * self, PyObject * args)
 534        {
 535            OCIO_PYTRY_ENTER()
 536            char* path = 0;
 537            if (!PyArg_ParseTuple(args, "s:setWorkingDir",
 538                &path)) return NULL;
 539            ConfigRcPtr config = GetEditableConfig(self);
 540            config->setWorkingDir(path);
 541            Py_RETURN_NONE;
 542            OCIO_PYTRY_EXIT(NULL)
 543        }
 544        
 545        PyObject * PyOCIO_Config_getNumColorSpaces(PyObject * self)
 546        {
 547            OCIO_PYTRY_ENTER()
 548            ConstConfigRcPtr config = GetConstConfig(self, true);
 549            return PyInt_FromLong(config->getNumColorSpaces());
 550            OCIO_PYTRY_EXIT(NULL)
 551        }
 552        
 553        PyObject * PyOCIO_Config_getColorSpaceNameByIndex(PyObject * self,  PyObject * args)
 554        {
 555            OCIO_PYTRY_ENTER()
 556            int index = 0;
 557            if (!PyArg_ParseTuple(args,"i:getColorSpaceNameByIndex",
 558                &index)) return NULL;
 559            ConstConfigRcPtr config = GetConstConfig(self, true);
 560            return PyString_FromString(config->getColorSpaceNameByIndex(index));
 561            OCIO_PYTRY_EXIT(NULL)
 562        }
 563        
 564        PyObject * PyOCIO_Config_getColorSpaces(PyObject * self)
 565        {
 566            OCIO_PYTRY_ENTER()
 567            ConstConfigRcPtr config = GetConstConfig(self, true);
 568            int numColorSpaces = config->getNumColorSpaces();
 569            PyObject* tuple = PyTuple_New(numColorSpaces);
 570            for(int i = 0; i < numColorSpaces; ++i)
 571            {
 572                const char* name = config->getColorSpaceNameByIndex(i);
 573                ConstColorSpaceRcPtr cs = config->getColorSpace(name);
 574                PyObject* pycs = BuildConstPyColorSpace(cs);
 575                PyTuple_SetItem(tuple, i, pycs);
 576            }
 577            return tuple;
 578            OCIO_PYTRY_EXIT(NULL)
 579        }
 580        
 581        PyObject * PyOCIO_Config_getColorSpace(PyObject * self, PyObject * args)
 582        {
 583            OCIO_PYTRY_ENTER()
 584            char* name = 0;
 585            if (!PyArg_ParseTuple(args,"s:getColorSpace",
 586                &name)) return NULL;
 587            ConstConfigRcPtr config = GetConstConfig(self, true);
 588            return BuildConstPyColorSpace(config->getColorSpace(name));
 589            OCIO_PYTRY_EXIT(NULL)
 590        }
 591        
 592        PyObject * PyOCIO_Config_getIndexForColorSpace(PyObject * self,  PyObject * args)
 593        {
 594            OCIO_PYTRY_ENTER()
 595            char* name = 0;
 596            if (!PyArg_ParseTuple(args,"s:getIndexForColorSpace",
 597                &name)) return NULL;
 598            ConstConfigRcPtr config = GetConstConfig(self, true);
 599            return PyInt_FromLong(config->getIndexForColorSpace(name));
 600            OCIO_PYTRY_EXIT(NULL)
 601        }
 602        
 603        PyObject * PyOCIO_Config_addColorSpace(PyObject * self, PyObject * args)
 604        {
 605            OCIO_PYTRY_ENTER()
 606            ConfigRcPtr config = GetEditableConfig(self);
 607            PyObject* pyColorSpace = 0;
 608            if (!PyArg_ParseTuple(args, "O:addColorSpace",
 609                &pyColorSpace)) return NULL;
 610            config->addColorSpace(GetConstColorSpace(pyColorSpace, true));
 611            Py_RETURN_NONE;
 612            OCIO_PYTRY_EXIT(NULL)
 613        }
 614        
 615        PyObject * PyOCIO_Config_clearColorSpaces(PyObject * self)
 616        {
 617            OCIO_PYTRY_ENTER()
 618            ConfigRcPtr config = GetEditableConfig(self);
 619            config->clearColorSpaces();
 620            Py_RETURN_NONE;
 621            OCIO_PYTRY_EXIT(NULL)
 622        }
 623        
 624        PyObject * PyOCIO_Config_parseColorSpaceFromString(PyObject * self, PyObject * args)
 625        {
 626            OCIO_PYTRY_ENTER()
 627            ConstConfigRcPtr config = GetConstConfig(self, true);
 628            char* str = 0;
 629            if (!PyArg_ParseTuple(args, "s:parseColorSpaceFromString",
 630                &str)) return NULL;
 631            const char* cs = config->parseColorSpaceFromString(str);
 632            if(cs) return PyString_FromString(cs);
 633            Py_RETURN_NONE;
 634            OCIO_PYTRY_EXIT(NULL)
 635        }
 636        
 637        PyObject * PyOCIO_Config_isStrictParsingEnabled(PyObject * self)
 638        {
 639            OCIO_PYTRY_ENTER()
 640            ConstConfigRcPtr config = GetConstConfig(self, true);
 641            return PyBool_FromLong(config->isStrictParsingEnabled());
 642            OCIO_PYTRY_EXIT(NULL)
 643        }
 644        
 645        PyObject * PyOCIO_Config_setStrictParsingEnabled(PyObject * self, PyObject * args)
 646        {
 647            OCIO_PYTRY_ENTER()
 648            bool enabled = false;
 649            if (!PyArg_ParseTuple(args, "O&:setStrictParsingEnabled",
 650                ConvertPyObjectToBool, &enabled)) return NULL;
 651            ConfigRcPtr config = GetEditableConfig(self);
 652            config->setStrictParsingEnabled(enabled);
 653            Py_RETURN_NONE;
 654            OCIO_PYTRY_EXIT(NULL)
 655        }
 656        
 657        PyObject * PyOCIO_Config_setRole(PyObject * self, PyObject * args)
 658        {
 659            OCIO_PYTRY_ENTER()
 660            ConfigRcPtr config = GetEditableConfig(self);
 661            char* role = 0;
 662            char* csname = 0;
 663            if (!PyArg_ParseTuple(args, "ss:setRole",
 664                &role, &csname)) return NULL;
 665            config->setRole(role, csname);
 666            Py_RETURN_NONE;
 667            OCIO_PYTRY_EXIT(NULL)
 668        }
 669        
 670        PyObject * PyOCIO_Config_getNumRoles(PyObject * self)
 671        {
 672            OCIO_PYTRY_ENTER()
 673            ConstConfigRcPtr config = GetConstConfig(self, true);
 674            return PyInt_FromLong(config->getNumRoles());
 675            OCIO_PYTRY_EXIT(NULL)
 676        }
 677        
 678        PyObject * PyOCIO_Config_hasRole(PyObject * self, PyObject * args)
 679        {
 680            OCIO_PYTRY_ENTER()
 681            char* str = 0;
 682            if (!PyArg_ParseTuple(args, "s:hasRole",
 683                &str)) return NULL;
 684            ConstConfigRcPtr config = GetConstConfig(self, true);
 685            return PyBool_FromLong(config->hasRole(str));
 686            OCIO_PYTRY_EXIT(NULL)
 687        }
 688        
 689        PyObject * PyOCIO_Config_getRoleName(PyObject * self, PyObject * args)
 690        {
 691            OCIO_PYTRY_ENTER()
 692            int index = 0;
 693            if (!PyArg_ParseTuple(args,"i:getRoleName",
 694                &index)) return NULL;
 695            ConstConfigRcPtr config = GetConstConfig(self, true);
 696            return PyString_FromString(config->getRoleName(index));
 697            OCIO_PYTRY_EXIT(NULL)
 698        }
 699        
 700        PyObject * PyOCIO_Config_getDefaultDisplay(PyObject * self)
 701        {
 702            OCIO_PYTRY_ENTER()
 703            ConstConfigRcPtr config = GetConstConfig(self, true);
 704            return PyString_FromString(config->getDefaultDisplay());
 705            OCIO_PYTRY_EXIT(NULL)
 706        }
 707        
 708        PyObject * PyOCIO_Config_getNumDisplays(PyObject * self)
 709        {
 710            OCIO_PYTRY_ENTER()
 711            ConstConfigRcPtr config = GetConstConfig(self, true);
 712            return PyInt_FromLong(config->getNumDisplays());
 713            OCIO_PYTRY_EXIT(NULL)
 714        }
 715        
 716        PyObject * PyOCIO_Config_getDisplay(PyObject * self, PyObject * args)
 717        {
 718            OCIO_PYTRY_ENTER()
 719            int index = 0;
 720            if (!PyArg_ParseTuple(args,"i:getDisplay",
 721                &index)) return NULL;
 722            ConstConfigRcPtr config = GetConstConfig(self, true);
 723            return PyString_FromString(config->getDisplay(index));
 724            OCIO_PYTRY_EXIT(NULL)
 725        }
 726        
 727        PyObject * PyOCIO_Config_getDisplays(PyObject * self)
 728        {
 729            OCIO_PYTRY_ENTER()
 730            ConstConfigRcPtr config = GetConstConfig(self, true);
 731            std::vector<std::string> data;
 732            int numDevices = config->getNumDisplays();
 733            for(int i = 0; i < numDevices; ++i)
 734                data.push_back(config->getDisplay(i));
 735            return CreatePyListFromStringVector(data);
 736            OCIO_PYTRY_EXIT(NULL)
 737        }
 738        
 739        PyObject * PyOCIO_Config_getDefaultView(PyObject * self, PyObject * args)
 740        {
 741            OCIO_PYTRY_ENTER()
 742            char* display = 0;
 743            if (!PyArg_ParseTuple(args, "s:getDefaultView",
 744                &display)) return NULL;
 745            ConstConfigRcPtr config = GetConstConfig(self, true);
 746            return PyString_FromString(config->getDefaultView(display));
 747            OCIO_PYTRY_EXIT(NULL)
 748        }
 749        
 750        PyObject * PyOCIO_Config_getNumViews(PyObject * self, PyObject * args)
 751        {
 752            OCIO_PYTRY_ENTER()
 753            char* display = 0;
 754            if (!PyArg_ParseTuple(args, "s:getNumViews",
 755                &display)) return NULL;
 756            ConstConfigRcPtr config = GetConstConfig(self, true);
 757            return PyInt_FromLong(config->getNumViews(display));
 758            OCIO_PYTRY_EXIT(NULL)
 759        }
 760        
 761        PyObject * PyOCIO_Config_getView(PyObject * self, PyObject * args)
 762        {
 763            OCIO_PYTRY_ENTER()
 764            char* display = 0;
 765            int index = 0;
 766            if (!PyArg_ParseTuple(args, "si:getNumViews",
 767                &display, &index)) return NULL;
 768            ConstConfigRcPtr config = GetConstConfig(self, true);
 769            return PyString_FromString(config->getView(display, index));
 770            OCIO_PYTRY_EXIT(NULL)
 771        }
 772        
 773        PyObject * PyOCIO_Config_getViews(PyObject * self, PyObject * args)
 774        {
 775            OCIO_PYTRY_ENTER()
 776            char* display = 0;
 777            if (!PyArg_ParseTuple(args, "s:getViews",
 778                &display)) return NULL;
 779            ConstConfigRcPtr config = GetConstConfig(self, true);
 780            std::vector<std::string> data;
 781            int num = config->getNumViews(display);
 782            for(int i=0; i < num; ++i)
 783                data.push_back(config->getView(display, i));
 784            return CreatePyListFromStringVector(data);
 785            OCIO_PYTRY_EXIT(NULL)
 786        }
 787        
 788        PyObject * PyOCIO_Config_getDisplayColorSpaceName(PyObject * self, PyObject * args)
 789        {
 790            OCIO_PYTRY_ENTER()
 791            char* display = 0;
 792            char* view = 0;
 793            if (!PyArg_ParseTuple(args, "ss:getDisplayColorSpaceName",
 794                &display, &view)) return NULL;
 795            ConstConfigRcPtr config = GetConstConfig(self, true);
 796            return PyString_FromString(config->getDisplayColorSpaceName(display, view));
 797            OCIO_PYTRY_EXIT(NULL)
 798        }
 799        
 800        PyObject * PyOCIO_Config_getDisplayLooks(PyObject * self, PyObject * args)
 801        {
 802            OCIO_PYTRY_ENTER()
 803            char* display = 0;
 804            char* view = 0;
 805            if (!PyArg_ParseTuple(args, "ss:getDisplayLooks",
 806                &display, &view)) return NULL;
 807            ConstConfigRcPtr config = GetConstConfig(self, true);
 808            return PyString_FromString(config->getDisplayLooks(display, view));
 809            OCIO_PYTRY_EXIT(NULL)
 810        }
 811        
 812        PyObject * PyOCIO_Config_addDisplay(PyObject * self, PyObject * args, PyObject * kwargs)
 813        {
 814            OCIO_PYTRY_ENTER()
 815            ConfigRcPtr config = GetEditableConfig(self);
 816            char* display = 0;
 817            char* view = 0;
 818            char* colorSpaceName = 0;
 819            char* looks = 0;
 820            const char * kwlist[] = { "display", "view", "colorSpaceName", "looks",  NULL };
 821            if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sss|s",
 822                const_cast<char**>(kwlist),
 823                &display, &view, &colorSpaceName, &looks))
 824                return 0;
 825            std::string lookStr;
 826            if(looks) lookStr = looks;
 827            config->addDisplay(display, view, colorSpaceName, lookStr.c_str());
 828            Py_RETURN_NONE;
 829            OCIO_PYTRY_EXIT(NULL)
 830        }
 831        
 832        PyObject * PyOCIO_Config_clearDisplays(PyObject * self)
 833        {
 834            OCIO_PYTRY_ENTER()
 835            ConfigRcPtr config = GetEditableConfig(self);
 836            config->clearDisplays();
 837            Py_RETURN_NONE;
 838            OCIO_PYTRY_EXIT(NULL)
 839        }
 840        
 841        PyObject * PyOCIO_Config_setActiveDisplays(PyObject * self, PyObject * args)
 842        {
 843            OCIO_PYTRY_ENTER()
 844            ConfigRcPtr config = GetEditableConfig(self);
 845            char* displays = 0;
 846            if (!PyArg_ParseTuple(args, "s:setActiveDisplays",
 847                &displays)) return NULL;
 848            config->setActiveDisplays(displays);
 849            Py_RETURN_NONE;
 850            OCIO_PYTRY_EXIT(NULL)
 851        }
 852        
 853        PyObject * PyOCIO_Config_getActiveDisplays(PyObject * self)
 854        {
 855            OCIO_PYTRY_ENTER()
 856            ConstConfigRcPtr config = GetConstConfig(self, true);
 857            return PyString_FromString(config->getActiveDisplays());
 858            OCIO_PYTRY_EXIT(NULL)
 859        }
 860        
 861        PyObject * PyOCIO_Config_setActiveViews(PyObject * self, PyObject * args)
 862        {
 863            OCIO_PYTRY_ENTER()
 864            ConfigRcPtr config = GetEditableConfig(self);
 865            char* views = 0;
 866            if (!PyArg_ParseTuple(args, "s:setActiveViews",
 867                &views)) return NULL;
 868            config->setActiveViews(views);
 869            Py_RETURN_NONE;
 870            OCIO_PYTRY_EXIT(NULL)
 871        }
 872        
 873        PyObject * PyOCIO_Config_getActiveViews(PyObject * self)
 874        {
 875            OCIO_PYTRY_ENTER()
 876            ConstConfigRcPtr config = GetConstConfig(self, true);
 877            return PyString_FromString(config->getActiveViews());
 878            OCIO_PYTRY_EXIT(NULL)
 879        }
 880        
 881        PyObject * PyOCIO_Config_setDefaultLumaCoefs(PyObject * self, PyObject * args)
 882        {
 883            OCIO_PYTRY_ENTER()
 884            ConfigRcPtr config = GetEditableConfig(self);
 885            PyObject* pyCoef = 0;
 886            if (!PyArg_ParseTuple(args, "O:setDefaultLumaCoefs",
 887                &pyCoef)) return 0;
 888            std::vector<float> coef;
 889            if(!FillFloatVectorFromPySequence(pyCoef, coef) || (coef.size() != 3))
 890            {
 891                PyErr_SetString(PyExc_TypeError, "First argument must be a float array, size 3");
 892                return 0;
 893            }
 894            config->setDefaultLumaCoefs(&coef[0]);
 895            Py_RETURN_NONE;
 896            OCIO_PYTRY_EXIT(NULL)
 897        }
 898        
 899        PyObject * PyOCIO_Config_getDefaultLumaCoefs(PyObject * self)
 900        {
 901            OCIO_PYTRY_ENTER()
 902            ConstConfigRcPtr config = GetConstConfig(self, true);
 903            std::vector<float> coef(3);
 904            config->getDefaultLumaCoefs(&coef[0]);
 905            return CreatePyListFromFloatVector(coef);
 906            OCIO_PYTRY_EXIT(NULL)
 907        }
 908        
 909        PyObject * PyOCIO_Config_getLook(PyObject * self, PyObject * args)
 910        {
 911            OCIO_PYTRY_ENTER()
 912            ConstConfigRcPtr config = GetConstConfig(self, true);
 913            char* str = 0;
 914            if (!PyArg_ParseTuple(args, "s:getLook",
 915                &str)) return NULL;
 916            return BuildConstPyLook(config->getLook(str));
 917            OCIO_PYTRY_EXIT(NULL)
 918        }
 919        
 920        PyObject * PyOCIO_Config_getNumLooks(PyObject * self)
 921        {
 922            OCIO_PYTRY_ENTER()
 923            ConstConfigRcPtr config = GetConstConfig(self, true);
 924            return PyInt_FromLong(config->getNumLooks());
 925            OCIO_PYTRY_EXIT(NULL)
 926        }
 927        
 928        PyObject * PyOCIO_Config_getLookNameByIndex(PyObject * self, PyObject * args)
 929        {
 930            OCIO_PYTRY_ENTER()
 931            int index = 0;
 932            if (!PyArg_ParseTuple(args,"i:getLookNameByIndex",
 933                &index)) return NULL;
 934            ConstConfigRcPtr config = GetConstConfig(self, true);
 935            return PyString_FromString(config->getLookNameByIndex(index));
 936            OCIO_PYTRY_EXIT(NULL)
 937        }
 938        
 939        PyObject * PyOCIO_Config_getLooks(PyObject * self)
 940        {
 941            OCIO_PYTRY_ENTER()
 942            ConstConfigRcPtr config = GetConstConfig(self, true);
 943            int num = config->getNumLooks();
 944            PyObject* tuple = PyTuple_New(num);
 945            for(int i = 0; i < num; ++i)
 946            {
 947                const char* name = config->getLookNameByIndex(i);
 948                ConstLookRcPtr look = config->getLook(name);
 949                PyObject* pylook = BuildConstPyLook(look);
 950                PyTuple_SetItem(tuple, i, pylook);
 951            }
 952            return tuple;
 953            OCIO_PYTRY_EXIT(NULL)
 954        }
 955        
 956        PyObject * PyOCIO_Config_addLook(PyObject * self, PyObject * args)
 957        {
 958            OCIO_PYTRY_ENTER()
 959            ConfigRcPtr config = GetEditableConfig(self);
 960            PyObject * pyLook = 0;
 961            if (!PyArg_ParseTuple(args, "O:addLook",
 962                &pyLook)) return NULL;
 963            config->addLook(GetConstLook(pyLook, true));
 964            Py_RETURN_NONE;
 965            OCIO_PYTRY_EXIT(NULL)
 966        }
 967        
 968        PyObject * PyOCIO_Config_clearLooks(PyObject * self)
 969        {
 970            OCIO_PYTRY_ENTER()
 971            ConfigRcPtr config = GetEditableConfig(self);
 972            config->clearLooks();
 973            Py_RETURN_NONE;
 974            OCIO_PYTRY_EXIT(NULL)
 975        }
 976        
 977        PyObject * PyOCIO_Config_getProcessor(PyObject * self, PyObject * args, PyObject * kwargs)
 978        {
 979            OCIO_PYTRY_ENTER()
 980            
 981            // We want this call to be as flexible as possible.
 982            // arg1 will either be a PyTransform
 983            // or arg1, arg2 will be {str, ColorSpace}
 984            PyObject* arg1 = Py_None;
 985            PyObject* arg2 = Py_None;
 986            
 987            const char* direction = 0;
 988            PyObject* pycontext = Py_None;
 989            
 990            const char* kwlist[] = { "arg1", "arg2", "direction", "context",  NULL };
 991            
 992            if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OsO",
 993                const_cast<char**>(kwlist),
 994                &arg1, &arg2, &direction, &pycontext)) return 0;
 995            
 996            ConstConfigRcPtr config = GetConstConfig(self, true);
 997            
 998            // Parse the direction string
 999            TransformDirection dir = TRANSFORM_DIR_FORWARD;
1000            if(direction) dir = TransformDirectionFromString(direction);
1001            
1002            // Parse the context
1003            ConstContextRcPtr context;
1004            if(pycontext != Py_None) context = GetConstContext(pycontext, true);
1005            if(!context) context = config->getCurrentContext();
1006                
1007            if(IsPyTransform(arg1)) {
1008                ConstTransformRcPtr transform = GetConstTransform(arg1, true);
1009                return BuildConstPyProcessor(config->getProcessor(context, transform, dir));
1010            }
1011            
1012            // Any two (Colorspaces, colorspace name, roles)
1013            ConstColorSpaceRcPtr cs1;
1014            if(IsPyColorSpace(arg1))
1015                cs1 = GetConstColorSpace(arg1, true);
1016            else if(PyString_Check(arg1))
1017                cs1 = config->getColorSpace(PyString_AsString(arg1));
1018            if(!cs1)
1019            {
1020                PyErr_SetString(PyExc_ValueError,
1021                    "Could not parse first arg. Allowed types include ColorSpace, ColorSpace name, Role.");
1022                return NULL;
1023            }
1024            
1025            ConstColorSpaceRcPtr cs2;
1026            if(IsPyColorSpace(arg2))
1027                cs2 = GetConstColorSpace(arg2, true);
1028            else if(PyString_Check(arg2))
1029                cs2 = config->getColorSpace(PyString_AsString(arg2));
1030            if(!cs2)
1031            {
1032                PyErr_SetString(PyExc_ValueError,
1033                    "Could not parse second arg. Allowed types include ColorSpace, ColorSpace name, Role.");
1034                return NULL;
1035            }
1036            
1037            return BuildConstPyProcessor(config->getProcessor(context, cs1, cs2));
1038            OCIO_PYTRY_EXIT(NULL)
1039        }
1040        
1041    }
1042
1043}
1044OCIO_NAMESPACE_EXIT