示例#1
0
static PyObject*  
cms_profile_getattro(CmsProfileObject* self, PyObject* name)
{
    PyObject* name_bytes;
    char* name_string;

    if (!PyUnicode_Check(name))
        return NULL;
   
    if (!(name_bytes = PyUnicode_AsASCIIString(name)))
        return NULL;

    if (!(name_string = PyBytes_AsString(name_bytes)))
        return NULL;

    if (!strcmp(name_string, "product_name"))
        return PyUnicode_FromFormat("%s", cmsTakeProductName(self->profile));
    if (!strcmp(name_string, "product_desc"))
        return PyUnicode_FromFormat("%s", cmsTakeProductDesc(self->profile));
    if (!strcmp(name_string, "product_info"))
        return PyUnicode_FromFormat("%s", cmsTakeProductInfo(self->profile));
    if (!strcmp(name_string, "rendering_intent"))
        return PyLong_FromLong(cmsTakeRenderingIntent(self->profile));
    if (!strcmp(name_string, "pcs"))
        return PyUnicode_FromFormat("%s", findICmode(cmsGetPCS(self->profile)));
    if (!strcmp(name_string, "color_space"))
        return PyUnicode_FromFormat("%s",
                findICmode(cmsGetColorSpace(self->profile)));
    /* FIXME: add more properties (creation_datetime etc) */

    return PyObject_GenericGetAttr((PyObject*)self, name);
}
示例#2
0
static PyObject*
cms_profile_getattr(CmsProfileObject* self, char* name)
{
#ifdef PY3
    if (!strcmp(name, "product_name"))
        return PyUnicode_DecodeFSDefault(cmsTakeProductName(self->profile));
    if (!strcmp(name, "product_desc"))
        return PyUnicode_DecodeFSDefault(cmsTakeProductDesc(self->profile));
    if (!strcmp(name, "product_info"))
        return PyUnicode_DecodeFSDefault(cmsTakeProductInfo(self->profile));
    if (!strcmp(name, "rendering_intent"))
        return PyLong_FromLong(cmsTakeRenderingIntent(self->profile));
    if (!strcmp(name, "pcs"))
        return PyUnicode_DecodeFSDefault(findICmode(cmsGetPCS(self->profile)));
    if (!strcmp(name, "color_space"))
        return PyUnicode_DecodeFSDefault(findICmode(cmsGetColorSpace(self->profile)));
    /* FIXME: add more properties (creation_datetime etc) */

    return PyObject_GenericGetAttr((PyObject *)self,
                                   PyUnicode_DecodeFSDefault(name));
#else
    if (!strcmp(name, "product_name"))
        return PyString_FromString(cmsTakeProductName(self->profile));
    if (!strcmp(name, "product_desc"))
        return PyString_FromString(cmsTakeProductDesc(self->profile));
    if (!strcmp(name, "product_info"))
        return PyString_FromString(cmsTakeProductInfo(self->profile));
    if (!strcmp(name, "rendering_intent"))
        return PyInt_FromLong(cmsTakeRenderingIntent(self->profile));
    if (!strcmp(name, "pcs"))
        return PyString_FromString(findICmode(cmsGetPCS(self->profile)));
    if (!strcmp(name, "color_space"))
        return PyString_FromString(findICmode(cmsGetColorSpace(self->profile)));
    /* FIXME: add more properties (creation_datetime etc) */

    return Py_FindMethod(cms_profile_methods, (PyObject*) self, name);
#endif
}
示例#3
0
文件: _imagingcms.c 项目: anex/Python
static PyObject*
cms_profile_getattr_rendering_intent(CmsProfileObject* self, void* closure)
{
    return PyInt_FromLong(cmsTakeRenderingIntent(self->profile));
}