Changeset 11704:02de8bb41dec in orange


Ignore:
Timestamp:
09/16/13 11:56:17 (7 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Added dedicated get/set for 'attributes' property of feature descriptors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/lib_kernel.cpp

    r11703 r11704  
    316316 
    317317 
     318/* 
     319 * Variable.attributes dictionary getter/setter 
     320 */ 
     321 
     322PyObject *Variable_get_attributes(TPyOrange *self) 
     323{ 
     324    PyObject *res = NULL; 
     325 
     326    if (self->orange_dict && (res = PyDict_GetItemString(self->orange_dict, "attributes"))) { 
     327        Py_INCREF(res); 
     328        return res; 
     329    } 
     330 
     331    PyObject *dict = PyDict_New(); 
     332    Orange_setattrDictionary(self, "attributes", dict, false); 
     333    return dict; 
     334} 
     335 
     336 
     337int Variable_set_attributes(TPyOrange *self, PyObject *dict) 
     338{ 
     339    if (!PyDict_Check(dict)) { 
     340        PYERROR(PyExc_TypeError, "'attributes' must be a dict", 0); 
     341    } 
     342    return Orange_setattrDictionary(self, "attributes", dict, false); 
     343} 
     344 
     345 
    318346#include "stringvars.hpp" 
    319347C_NAMED(StringVariable - Orange.feature.String, Variable, "([name=])") 
     
    366394} 
    367395 
    368  
    369 PyObject *Variable_getattr(TPyOrange *self, PyObject *name) 
    370 { 
    371   if (PyString_Check(name) && !strcmp(PyString_AsString(name), "attributes") 
    372       && (!self->orange_dict || !PyDict_Contains(self->orange_dict, name))) { 
    373     PyObject *dict = PyDict_New(); 
    374     Orange_setattrDictionary(self, name, dict, false); 
    375     Py_DECREF(dict); 
    376   } 
    377  
    378   return Orange_getattr(self, name); 
    379 } 
    380396 
    381397PyObject *Variable_randomvalue(PyObject *self, PyObject *args) PYARGS(0, "() -> Value") 
Note: See TracChangeset for help on using the changeset viewer.