return 0;
}
-/*static PyObject *PluginData_repr(PyObject *s) {
+static PyObject *PluginData_repr(PyObject *s) {
+ PyObject *ret, *tmp;
+ static PyObject *l_type = NULL, *l_type_instance = NULL, *l_plugin = NULL, *l_plugin_instance = NULL;
+ static PyObject *l_host = NULL, *l_time = NULL, *l_closing = NULL;
PluginData *self = (PluginData *) s;
- return PyString_FromFormat("collectd.Values(type='%s%s%s%s%s%s%s%s%s',time=%lu)", self->type,
- *self->type_instance ? "',type_instance='" : "", self->type_instance,
- *self->plugin ? "',plugin='" : "", self->plugin,
- *self->plugin_instance ? "',plugin_instance='" : "", self->plugin_instance,
- *self->host ? "',host='" : "", self->host,
- (long unsigned) self->time);
-}*/
+ if (l_type == NULL)
+ l_type = cpy_string_to_unicode_or_bytes("(type=");
+ if (l_type_instance == NULL)
+ l_type_instance = cpy_string_to_unicode_or_bytes(",type_instance=");
+ if (l_plugin == NULL)
+ l_plugin = cpy_string_to_unicode_or_bytes(",plugin=");
+ if (l_plugin_instance == NULL)
+ l_plugin_instance = cpy_string_to_unicode_or_bytes(",plugin_instance=");
+ if (l_host == NULL)
+ l_host = cpy_string_to_unicode_or_bytes(",host=");
+ if (l_time == NULL)
+ l_time = cpy_string_to_unicode_or_bytes(",time=");
+ if (l_closing == NULL)
+ l_closing = cpy_string_to_unicode_or_bytes(")");
+
+ if (!l_type || !l_type_instance || !l_plugin || !l_plugin_instance || !l_host || !l_time)
+ return NULL;
+
+ ret = cpy_string_to_unicode_or_bytes(s->ob_type->tp_name);
+
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, l_type);
+ tmp = cpy_string_to_unicode_or_bytes(self->type);
+ CPY_SUBSTITUTE(PyObject_Repr, tmp, tmp);
+ if (tmp)
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, tmp);
+ Py_XDECREF(tmp);
+
+ if (self->type_instance[0] != 0) {
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, l_type_instance);
+ tmp = cpy_string_to_unicode_or_bytes(self->type_instance);
+ CPY_SUBSTITUTE(PyObject_Repr, tmp, tmp);
+ if (tmp)
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, tmp);
+ Py_XDECREF(tmp);
+ }
+
+ if (self->plugin[0] != 0) {
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, l_plugin);
+ tmp = cpy_string_to_unicode_or_bytes(self->plugin);
+ CPY_SUBSTITUTE(PyObject_Repr, tmp, tmp);
+ if (tmp)
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, tmp);
+ Py_XDECREF(tmp);
+ }
+
+ if (self->plugin_instance[0] != 0) {
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, l_plugin_instance);
+ tmp = cpy_string_to_unicode_or_bytes(self->plugin_instance);
+ CPY_SUBSTITUTE(PyObject_Repr, tmp, tmp);
+ if (tmp)
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, tmp);
+ Py_XDECREF(tmp);
+ }
+
+ if (self->host[0] != 0) {
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, l_host);
+ tmp = cpy_string_to_unicode_or_bytes(self->host);
+ CPY_SUBSTITUTE(PyObject_Repr, tmp, tmp);
+ if (tmp)
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, tmp);
+ Py_XDECREF(tmp);
+ }
+
+ if (self->time != 0) {
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, l_time);
+ tmp = PyInt_FromLong(self->time);
+ CPY_SUBSTITUTE(PyObject_Repr, tmp, tmp);
+ if (tmp)
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, tmp);
+ Py_XDECREF(tmp);
+ }
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, l_closing);
+ return ret;
+}
static PyMemberDef PluginData_members[] = {
{"time", T_DOUBLE, offsetof(PluginData, time), 0, time_doc},
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
- 0/*PluginData_repr*/, /* tp_repr */
+ PluginData_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
static char *kwlist[] = {"type", "values", "plugin_instance", "type_instance",
"plugin", "host", "time", "interval", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|sOssssdi", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|sOzsssdi", kwlist,
&type, &values, &plugin_instance, &type_instance,
&plugin, &host, &time, &interval))
return NULL;