| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
#ifdef HAVE_CONFIG_H |
|---|
| 20 |
#include "config.h" |
|---|
| 21 |
#endif |
|---|
| 22 |
|
|---|
| 23 |
#define NO_IMPORT_PYGOBJECT |
|---|
| 24 |
#include "py_midgard.h" |
|---|
| 25 |
|
|---|
| 26 |
PyTypeObject G_GNUC_INTERNAL Pymidgard_collector_Type; |
|---|
| 27 |
|
|---|
| 28 |
#define COLLECTOR_DEBUG(__name) \ |
|---|
| 29 |
CHECK_MGD; \ |
|---|
| 30 |
CLASS_METHOD_DEBUG(Pymidgard_collector_Type.tp_name, __name); |
|---|
| 31 |
|
|---|
| 32 |
static int |
|---|
| 33 |
__collector_constructor(PyGObject *self, PyObject *args, PyObject *kwargs) |
|---|
| 34 |
{ |
|---|
| 35 |
COLLECTOR_DEBUG("__init__"); |
|---|
| 36 |
const gchar *classname; |
|---|
| 37 |
const gchar *domain; |
|---|
| 38 |
PyObject *pvalue = NULL; |
|---|
| 39 |
GValue *cvalue = NULL; |
|---|
| 40 |
if(!PyArg_ParseTuple(args, "ssO", &classname, &domain, &pvalue)) |
|---|
| 41 |
return -1; |
|---|
| 42 |
|
|---|
| 43 |
MidgardConnection *mgd = |
|---|
| 44 |
_py_midgard_connection_singleton_get(); |
|---|
| 45 |
|
|---|
| 46 |
if(pvalue != NULL) { |
|---|
| 47 |
|
|---|
| 48 |
GValue gval = gvalue_from_pyobject(pvalue); |
|---|
| 49 |
pyg_value_from_pyobject(&gval, pvalue); |
|---|
| 50 |
cvalue = g_new0(GValue, 1); |
|---|
| 51 |
g_value_init(cvalue, G_VALUE_TYPE(&gval)); |
|---|
| 52 |
g_value_copy((const GValue *) &gval, cvalue); |
|---|
| 53 |
g_value_unset(&gval); |
|---|
| 54 |
} |
|---|
| 55 |
|
|---|
| 56 |
MidgardCollector *mc = |
|---|
| 57 |
midgard_collector_new(mgd, classname, domain, cvalue); |
|---|
| 58 |
|
|---|
| 59 |
if(!mc) return -1; |
|---|
| 60 |
|
|---|
| 61 |
self->obj = G_OBJECT(mc); |
|---|
| 62 |
|
|---|
| 63 |
return 0; |
|---|
| 64 |
} |
|---|
| 65 |
|
|---|
| 66 |
static PyObject * |
|---|
| 67 |
pymidgard_collector_set_key_property(PyGObject *self, PyObject *args) |
|---|
| 68 |
{ |
|---|
| 69 |
COLLECTOR_DEBUG("set_key_property"); |
|---|
| 70 |
const gchar *key; |
|---|
| 71 |
PyObject *pvalue = NULL; |
|---|
| 72 |
GValue *cvalue = NULL; |
|---|
| 73 |
|
|---|
| 74 |
if(!PyArg_ParseTuple(args, "s|O", &key, &pvalue)) |
|---|
| 75 |
return NULL; |
|---|
| 76 |
|
|---|
| 77 |
if(pvalue != NULL) { |
|---|
| 78 |
|
|---|
| 79 |
GValue gval = gvalue_from_pyobject(pvalue); |
|---|
| 80 |
pyg_value_from_pyobject(&gval, pvalue); |
|---|
| 81 |
cvalue = g_new0(GValue, 1); |
|---|
| 82 |
g_value_init(cvalue, G_VALUE_TYPE(&gval)); |
|---|
| 83 |
g_value_copy((const GValue *) &gval, cvalue); |
|---|
| 84 |
g_value_unset(&gval); |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
if(midgard_collector_set_key_property( |
|---|
| 88 |
MIDGARD_COLLECTOR(self->obj), key, cvalue)) |
|---|
| 89 |
Py_RETURN_TRUE; |
|---|
| 90 |
|
|---|
| 91 |
Py_RETURN_FALSE; |
|---|
| 92 |
} |
|---|
| 93 |
|
|---|
| 94 |
static PyObject * |
|---|
| 95 |
pymidgard_collector_add_value_property(PyGObject *self, PyObject *args) |
|---|
| 96 |
{ |
|---|
| 97 |
COLLECTOR_DEBUG("add_value_property"); |
|---|
| 98 |
const gchar *property; |
|---|
| 99 |
|
|---|
| 100 |
if(!PyArg_ParseTuple(args, "s", &property)) |
|---|
| 101 |
return NULL; |
|---|
| 102 |
|
|---|
| 103 |
if(midgard_collector_add_value_property( |
|---|
| 104 |
MIDGARD_COLLECTOR(self->obj), property)) |
|---|
| 105 |
Py_RETURN_TRUE; |
|---|
| 106 |
|
|---|
| 107 |
Py_RETURN_FALSE; |
|---|
| 108 |
} |
|---|
| 109 |
|
|---|
| 110 |
static PyObject * |
|---|
| 111 |
pymidgard_collector_set(PyGObject *self, PyObject *args) |
|---|
| 112 |
{ |
|---|
| 113 |
COLLECTOR_DEBUG("set"); |
|---|
| 114 |
const gchar *key, *subkey; |
|---|
| 115 |
PyObject *pvalue = NULL; |
|---|
| 116 |
GValue *cvalue = NULL; |
|---|
| 117 |
|
|---|
| 118 |
if(!PyArg_ParseTuple(args, "ssO", &key, &subkey, &pvalue)) |
|---|
| 119 |
return NULL; |
|---|
| 120 |
|
|---|
| 121 |
if(pvalue != NULL) { |
|---|
| 122 |
|
|---|
| 123 |
GValue gval = gvalue_from_pyobject(pvalue); |
|---|
| 124 |
pyg_value_from_pyobject(&gval, pvalue); |
|---|
| 125 |
cvalue = g_new0(GValue, 1); |
|---|
| 126 |
g_value_init(cvalue, G_VALUE_TYPE(&gval)); |
|---|
| 127 |
g_value_copy((const GValue *) &gval, cvalue); |
|---|
| 128 |
g_value_unset(&gval); |
|---|
| 129 |
} |
|---|
| 130 |
|
|---|
| 131 |
if(midgard_collector_set(MIDGARD_COLLECTOR(self->obj), key, subkey, cvalue)) |
|---|
| 132 |
Py_RETURN_TRUE; |
|---|
| 133 |
|
|---|
| 134 |
Py_RETURN_FALSE; |
|---|
| 135 |
} |
|---|
| 136 |
|
|---|
| 137 |
static void __count_gdata_keys(GQuark key_id, |
|---|
| 138 |
gpointer data, gpointer user_data) |
|---|
| 139 |
{ |
|---|
| 140 |
MidgardTypeHolder *holder = (MidgardTypeHolder *) user_data; |
|---|
| 141 |
holder->elements++; |
|---|
| 142 |
} |
|---|
| 143 |
|
|---|
| 144 |
static void __update_list(GQuark key_id, |
|---|
| 145 |
gpointer data, gpointer user_data) |
|---|
| 146 |
{ |
|---|
| 147 |
PyObject *list = (PyObject *) user_data; |
|---|
| 148 |
PyObject *pvalue; |
|---|
| 149 |
GValue *gvalue = (GValue *) data; |
|---|
| 150 |
|
|---|
| 151 |
if(gvalue == NULL) |
|---|
| 152 |
return; |
|---|
| 153 |
|
|---|
| 154 |
pyg_value_from_pyobject(gvalue, pvalue); |
|---|
| 155 |
gint i = PyTuple_Size(list); |
|---|
| 156 |
PyTuple_SetItem(list, i++, pvalue); |
|---|
| 157 |
} |
|---|
| 158 |
|
|---|
| 159 |
static PyObject * |
|---|
| 160 |
pymidgard_collector_get(PyGObject *self, PyObject *args) |
|---|
| 161 |
{ |
|---|
| 162 |
COLLECTOR_DEBUG("get"); |
|---|
| 163 |
const gchar *key; |
|---|
| 164 |
|
|---|
| 165 |
if(!PyArg_ParseTuple(args, "s", &key)) |
|---|
| 166 |
return NULL; |
|---|
| 167 |
|
|---|
| 168 |
GData *keyslist = |
|---|
| 169 |
midgard_collector_get(MIDGARD_COLLECTOR(self->obj), key); |
|---|
| 170 |
|
|---|
| 171 |
if(keyslist == NULL) |
|---|
| 172 |
Py_RETURN_NONE; |
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
MidgardTypeHolder *holder = g_new(MidgardTypeHolder, 1); |
|---|
| 176 |
g_datalist_foreach(&keyslist, __count_gdata_keys, holder); |
|---|
| 177 |
PyObject *list = PyTuple_New(holder->elements); |
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
g_datalist_foreach(&keyslist, __update_list, list); |
|---|
| 181 |
return list; |
|---|
| 182 |
} |
|---|
| 183 |
|
|---|
| 184 |
static PyObject * |
|---|
| 185 |
pymidgard_collector_get_subkey(PyGObject *self, PyObject *args) |
|---|
| 186 |
{ |
|---|
| 187 |
COLLECTOR_DEBUG("get_subkey"); |
|---|
| 188 |
const gchar *key, *subkey; |
|---|
| 189 |
|
|---|
| 190 |
if(!PyArg_ParseTuple(args, "ss", &key, &subkey)) |
|---|
| 191 |
return NULL; |
|---|
| 192 |
|
|---|
| 193 |
GValue *gval = |
|---|
| 194 |
midgard_collector_get_subkey(MIDGARD_COLLECTOR(self->obj), key, subkey); |
|---|
| 195 |
|
|---|
| 196 |
if(gval == NULL) |
|---|
| 197 |
Py_RETURN_NONE; |
|---|
| 198 |
|
|---|
| 199 |
PyObject *pvalue = pyg_value_as_pyobject((const GValue *)gval, FALSE); |
|---|
| 200 |
|
|---|
| 201 |
return pvalue; |
|---|
| 202 |
} |
|---|
| 203 |
|
|---|
| 204 |
static PyObject * |
|---|
| 205 |
pymidgard_collector_list_keys(PyGObject *self, PyObject *args) |
|---|
| 206 |
{ |
|---|
| 207 |
COLLECTOR_DEBUG("list_keys"); |
|---|
| 208 |
|
|---|
| 209 |
if(!PyArg_ParseTuple(args, "")) |
|---|
| 210 |
return NULL; |
|---|
| 211 |
|
|---|
| 212 |
guint i = 0; |
|---|
| 213 |
PyObject *list; |
|---|
| 214 |
gchar **keys = |
|---|
| 215 |
midgard_collector_list_keys(MIDGARD_COLLECTOR(self->obj)); |
|---|
| 216 |
|
|---|
| 217 |
if(keys == NULL) { |
|---|
| 218 |
|
|---|
| 219 |
list = PyTuple_New(i); |
|---|
| 220 |
return list; |
|---|
| 221 |
} |
|---|
| 222 |
|
|---|
| 223 |
while(keys[i] != NULL) |
|---|
| 224 |
i++; |
|---|
| 225 |
|
|---|
| 226 |
list = PyTuple_New(i); |
|---|
| 227 |
|
|---|
| 228 |
i = 0; |
|---|
| 229 |
while(keys[i] != NULL) { |
|---|
| 230 |
|
|---|
| 231 |
PyObject *strname = PyString_FromString(keys[i]); |
|---|
| 232 |
PyTuple_SetItem(list, i, strname); |
|---|
| 233 |
i++; |
|---|
| 234 |
} |
|---|
| 235 |
|
|---|
| 236 |
g_free(keys); |
|---|
| 237 |
|
|---|
| 238 |
return list; |
|---|
| 239 |
} |
|---|
| 240 |
|
|---|
| 241 |
static PyObject * |
|---|
| 242 |
pymidgard_collector_merge(PyGObject *self, PyObject *args) |
|---|
| 243 |
{ |
|---|
| 244 |
COLLECTOR_DEBUG("merge"); |
|---|
| 245 |
PyObject *pmc; |
|---|
| 246 |
gboolean overwrite = FALSE; |
|---|
| 247 |
|
|---|
| 248 |
if(!PyArg_ParseTuple(args, "O|b", &pmc, &overwrite)) |
|---|
| 249 |
return NULL; |
|---|
| 250 |
|
|---|
| 251 |
MidgardCollector *mc = MIDGARD_COLLECTOR(((PyGObject *)pmc)->obj); |
|---|
| 252 |
MidgardCollector *uc = MIDGARD_COLLECTOR(self->obj); |
|---|
| 253 |
|
|---|
| 254 |
if(midgard_collector_merge(uc, mc, overwrite)) |
|---|
| 255 |
Py_RETURN_TRUE; |
|---|
| 256 |
|
|---|
| 257 |
Py_RETURN_FALSE; |
|---|
| 258 |
} |
|---|
| 259 |
|
|---|
| 260 |
static PyObject * |
|---|
| 261 |
pymidgard_collector_remove_key(PyGObject *self, PyObject *args) |
|---|
| 262 |
{ |
|---|
| 263 |
COLLECTOR_DEBUG("remove_key"); |
|---|
| 264 |
const gchar *key; |
|---|
| 265 |
|
|---|
| 266 |
if(!PyArg_ParseTuple(args, "s", &key)) |
|---|
| 267 |
return NULL; |
|---|
| 268 |
|
|---|
| 269 |
if(midgard_collector_remove_key(MIDGARD_COLLECTOR(self->obj), key)) |
|---|
| 270 |
Py_RETURN_TRUE; |
|---|
| 271 |
|
|---|
| 272 |
Py_RETURN_FALSE; |
|---|
| 273 |
} |
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 |
static PyObject * |
|---|
| 278 |
pymidgard_collector_add_constraint(PyGObject *self, PyObject *args) |
|---|
| 279 |
{ |
|---|
| 280 |
COLLECTOR_DEBUG("add_constraint"); |
|---|
| 281 |
const gchar *prop, *op; |
|---|
| 282 |
PyObject *pvalue; |
|---|
| 283 |
gboolean added; |
|---|
| 284 |
if(!PyArg_ParseTuple(args, "ssO", &prop, &op, &pvalue)) |
|---|
| 285 |
return NULL; |
|---|
| 286 |
|
|---|
| 287 |
MidgardCollector *collector = |
|---|
| 288 |
MIDGARD_COLLECTOR(self->obj); |
|---|
| 289 |
|
|---|
| 290 |
GValue gval = gvalue_from_pyobject(pvalue); |
|---|
| 291 |
pyg_value_from_pyobject(&gval, pvalue); |
|---|
| 292 |
|
|---|
| 293 |
added = midgard_collector_add_constraint(collector, prop, op, &gval); |
|---|
| 294 |
|
|---|
| 295 |
if(added) |
|---|
| 296 |
Py_RETURN_TRUE; |
|---|
| 297 |
|
|---|
| 298 |
Py_RETURN_FALSE; |
|---|
| 299 |
} |
|---|
| 300 |
|
|---|
| 301 |
static PyObject * |
|---|
| 302 |
pymidgard_collector_add_constraint_with_property(PyGObject *self, PyObject *args) |
|---|
| 303 |
{ |
|---|
| 304 |
COLLECTOR_DEBUG("add_constraint_with_property"); |
|---|
| 305 |
const gchar *prop_a, *op, *prop_b; |
|---|
| 306 |
PyObject *pvalue; |
|---|
| 307 |
gboolean added; |
|---|
| 308 |
if(!PyArg_ParseTuple(args, "sss", &prop_a, &op, &prop_b)) |
|---|
| 309 |
return NULL; |
|---|
| 310 |
|
|---|
| 311 |
MidgardCollector *collector = |
|---|
| 312 |
MIDGARD_COLLECTOR(self->obj); |
|---|
| 313 |
|
|---|
| 314 |
added = midgard_collector_add_constraint_with_property( |
|---|
| 315 |
collector, prop_a, op, prop_b); |
|---|
| 316 |
|
|---|
| 317 |
if(added) |
|---|
| 318 |
Py_RETURN_TRUE; |
|---|
| 319 |
|
|---|
| 320 |
Py_RETURN_FALSE; |
|---|
| 321 |
} |
|---|
| 322 |
|
|---|
| 323 |
static PyObject * |
|---|
| 324 |
pymidgard_collector_set_lang(PyGObject *self, PyObject *args) |
|---|
| 325 |
{ |
|---|
| 326 |
COLLECTOR_DEBUG("set_lang"); |
|---|
| 327 |
guint lang; |
|---|
| 328 |
if(!PyArg_ParseTuple(args, "i", &lang)) |
|---|
| 329 |
return NULL; |
|---|
| 330 |
|
|---|
| 331 |
MidgardCollector *collector = |
|---|
| 332 |
MIDGARD_COLLECTOR(self->obj); |
|---|
| 333 |
|
|---|
| 334 |
midgard_collector_set_lang(collector, lang); |
|---|
| 335 |
|
|---|
| 336 |
return Py_None; |
|---|
| 337 |
} |
|---|
| 338 |
|
|---|
| 339 |
static PyObject * |
|---|
| 340 |
pymidgard_collector_unset_languages(PyGObject *self, PyObject *args) |
|---|
| 341 |
{ |
|---|
| 342 |
COLLECTOR_DEBUG("unset_languages"); |
|---|
| 343 |
|
|---|
| 344 |
if(!PyArg_ParseTuple(args, "")) |
|---|
| 345 |
return NULL; |
|---|
| 346 |
|
|---|
| 347 |
MidgardCollector *collector = |
|---|
| 348 |
MIDGARD_COLLECTOR(self->obj); |
|---|
| 349 |
|
|---|
| 350 |
midgard_collector_unset_languages(collector); |
|---|
| 351 |
|
|---|
| 352 |
return Py_None; |
|---|
| 353 |
} |
|---|
| 354 |
|
|---|
| 355 |
static PyObject * |
|---|
| 356 |
pymidgard_collector_begin_group(PyGObject *self, PyObject *args) |
|---|
| 357 |
{ |
|---|
| 358 |
COLLECTOR_DEBUG("begin_group"); |
|---|
| 359 |
const gchar *group_op; |
|---|
| 360 |
if(!PyArg_ParseTuple(args, "s", &group_op)) |
|---|
| 361 |
return NULL; |
|---|
| 362 |
|
|---|
| 363 |
MidgardCollector *collector = |
|---|
| 364 |
MIDGARD_COLLECTOR(self->obj); |
|---|
| 365 |
|
|---|
| 366 |
if(midgard_collector_begin_group(collector, group_op)) |
|---|
| 367 |
Py_RETURN_TRUE; |
|---|
| 368 |
|
|---|
| 369 |
Py_RETURN_FALSE; |
|---|
| 370 |
} |
|---|
| 371 |
|
|---|
| 372 |
static PyObject * |
|---|
| 373 |
pymidgard_collector_end_group(PyGObject *self, PyObject *args) |
|---|
| 374 |
{ |
|---|
| 375 |
COLLECTOR_DEBUG("end_group"); |
|---|
| 376 |
|
|---|
| 377 |
if(!PyArg_ParseTuple(args, "")) |
|---|
| 378 |
return NULL; |
|---|
| 379 |
|
|---|
| 380 |
MidgardCollector *collector = |
|---|
| 381 |
MIDGARD_COLLECTOR(self->obj); |
|---|
| 382 |
|
|---|
| 383 |
if(midgard_collector_end_group(collector)) |
|---|
| 384 |
Py_RETURN_TRUE; |
|---|
| 385 |
|
|---|
| 386 |
Py_RETURN_FALSE; |
|---|
| 387 |
} |
|---|
| 388 |
|
|---|
| 389 |
static PyObject * |
|---|
| 390 |
pymidgard_collector_add_order(PyGObject *self, PyObject *args) |
|---|
| 391 |
{ |
|---|
| 392 |
COLLECTOR_DEBUG("add_order"); |
|---|
| 393 |
|
|---|
| 394 |
const gchar *prop, *order; |
|---|
| 395 |
if(!PyArg_ParseTuple(args, "ss", &prop, &order)) |
|---|
| 396 |
return NULL; |
|---|
| 397 |
|
|---|
| 398 |
MidgardCollector *collector = |
|---|
| 399 |
MIDGARD_COLLECTOR(self->obj); |
|---|
| 400 |
|
|---|
| 401 |
if(midgard_collector_add_order(collector, prop, order)) |
|---|
| 402 |
Py_RETURN_TRUE; |
|---|
| 403 |
|
|---|
| 404 |
Py_RETURN_FALSE; |
|---|
| 405 |
} |
|---|
| 406 |
|
|---|
| 407 |
static PyObject * |
|---|
| 408 |
pymidgard_collector_set_offset(PyGObject *self, PyObject *args) |
|---|
| 409 |
{ |
|---|
| 410 |
COLLECTOR_DEBUG("set_offset"); |
|---|
| 411 |
|
|---|
| 412 |
guint offset; |
|---|
| 413 |
if(!PyArg_ParseTuple(args, "i", &offset)) |
|---|
| 414 |
return NULL; |
|---|
| 415 |
|
|---|
| 416 |
MidgardCollector *collector = |
|---|
| 417 |
MIDGARD_COLLECTOR(self->obj); |
|---|
| 418 |
|
|---|
| 419 |
midgard_collector_set_offset(collector, offset); |
|---|
| 420 |
|
|---|
| 421 |
return Py_None; |
|---|
| 422 |
} |
|---|
| 423 |
|
|---|
| 424 |
static PyObject * |
|---|
| 425 |
pymidgard_collector_set_limit(PyGObject *self, PyObject *args) |
|---|
| 426 |
{ |
|---|
| 427 |
COLLECTOR_DEBUG("set_limit"); |
|---|
| 428 |
|
|---|
| 429 |
long limit; |
|---|
| 430 |
if(!PyArg_ParseTuple(args, "l", &limit)) |
|---|
| 431 |
return NULL; |
|---|
| 432 |
|
|---|
| 433 |
MidgardCollector *collector = |
|---|
| 434 |
MIDGARD_COLLECTOR(self->obj); |
|---|
| 435 |
|
|---|
| 436 |
midgard_collector_set_limit(collector, limit); |
|---|
| 437 |
|
|---|
| 438 |
return Py_None; |
|---|
| 439 |
} |
|---|
| 440 |
|
|---|
| 441 |
static PyObject * |
|---|
| 442 |
pymidgard_collector_count(PyGObject *self, PyObject *args) |
|---|
| 443 |
{ |
|---|
| 444 |
COLLECTOR_DEBUG("count"); |
|---|
| 445 |
|
|---|
| 446 |
if(!PyArg_ParseTuple(args, "")) |
|---|
| 447 |
return NULL; |
|---|
| 448 |
|
|---|
| 449 |
MidgardCollector *collector = |
|---|
| 450 |
MIDGARD_COLLECTOR(self->obj); |
|---|
| 451 |
|
|---|
| 452 |
|
|---|
| 453 |
|
|---|
| 454 |
|
|---|
| 455 |
|
|---|
| 456 |
|
|---|
| 457 |
} |
|---|
| 458 |
|
|---|
| 459 |
static PyObject * |
|---|
| 460 |
pymidgard_collector_include_deleted(PyGObject *self, PyObject *args) |
|---|
| 461 |
{ |
|---|
| 462 |
COLLECTOR_DEBUG("include_deleted"); |
|---|
| 463 |
|
|---|
| 464 |
if(!PyArg_ParseTuple(args, "")) |
|---|
| 465 |
return NULL; |
|---|
| 466 |
|
|---|
| 467 |
MidgardCollector *collector = |
|---|
| 468 |
MIDGARD_COLLECTOR(self->obj); |
|---|
| 469 |
|
|---|
| 470 |
midgard_collector_include_deleted(collector); |
|---|
| 471 |
|
|---|
| 472 |
return Py_None; |
|---|
| 473 |
} |
|---|
| 474 |
|
|---|
| 475 |
static PyObject * |
|---|
| 476 |
pymidgard_collector_execute(PyGObject *self, PyObject *args) |
|---|
| 477 |
{ |
|---|
| 478 |
COLLECTOR_DEBUG("execute"); |
|---|
| 479 |
|
|---|
| 480 |
if(!PyArg_ParseTuple(args, "")) |
|---|
| 481 |
return NULL; |
|---|
| 482 |
|
|---|
| 483 |
midgard_collector_execute(MIDGARD_COLLECTOR(self->obj)); |
|---|
| 484 |
|
|---|
| 485 |
Py_RETURN_NONE; |
|---|
| 486 |
} |
|---|
| 487 |
|
|---|
| 488 |
static PyMethodDef pymidgard_collector_methods[] = { |
|---|
| 489 |
{ "set_key_property", (PyCFunction)pymidgard_collector_set_key_property, METH_VARARGS }, |
|---|
| 490 |
{ "add_value_property", (PyCFunction)pymidgard_collector_add_value_property, METH_VARARGS }, |
|---|
| 491 |
{ "set", (PyCFunction)pymidgard_collector_set, METH_VARARGS }, |
|---|
| 492 |
{ "get", (PyCFunction)pymidgard_collector_get, METH_VARARGS }, |
|---|
| 493 |
{ "get_subkey", (PyCFunction)pymidgard_collector_get_subkey, METH_VARARGS }, |
|---|
| 494 |
{ "list_keys", (PyCFunction)pymidgard_collector_list_keys, METH_VARARGS }, |
|---|
| 495 |
{ "merge", (PyCFunction)pymidgard_collector_merge, METH_VARARGS }, |
|---|
| 496 |
{ "remove_key", (PyCFunction)pymidgard_collector_remove_key, METH_VARARGS }, |
|---|
| 497 |
{ "add_constraint", (PyCFunction)pymidgard_collector_add_constraint, METH_VARARGS }, |
|---|
| 498 |
{ "add_constraint_with_property", |
|---|
| 499 |
(PyCFunction)pymidgard_collector_add_constraint_with_property, METH_VARARGS }, |
|---|
| 500 |
{ "set_lang", (PyCFunction)pymidgard_collector_set_lang, METH_VARARGS }, |
|---|
| 501 |
{ "unset_languages", (PyCFunction)pymidgard_collector_unset_languages, METH_VARARGS }, |
|---|
| 502 |
{ "begin_group", (PyCFunction)pymidgard_collector_begin_group, METH_VARARGS }, |
|---|
| 503 |
{ "end_group", (PyCFunction)pymidgard_collector_end_group, METH_VARARGS }, |
|---|
| 504 |
{ "set_offset", (PyCFunction)pymidgard_collector_set_offset, METH_VARARGS }, |
|---|
| 505 |
{ "set_limit", (PyCFunction)pymidgard_collector_set_limit, METH_VARARGS }, |
|---|
| 506 |
{ "add_order", (PyCFunction)pymidgard_collector_add_order, METH_VARARGS }, |
|---|
| 507 |
{ "include_deleted", (PyCFunction)pymidgard_collector_include_deleted, METH_VARARGS }, |
|---|
| 508 |
{ "count", (PyCFunction)pymidgard_collector_count, METH_VARARGS }, |
|---|
| 509 |
|
|---|
| 510 |
{ "execute", (PyCFunction)pymidgard_collector_execute, METH_VARARGS }, |
|---|
| 511 |
{ NULL, NULL, 0 } |
|---|
| 512 |
}; |
|---|
| 513 |
|
|---|
| 514 |
PyTypeObject G_GNUC_INTERNAL Pymidgard_collector_Type = { |
|---|
| 515 |
PyObject_HEAD_INIT(NULL) |
|---|
| 516 |
0, |
|---|
| 517 |
"collector", |
|---|
| 518 |
sizeof(PyGObject), |
|---|
| 519 |
0, |
|---|
| 520 |
|
|---|
| 521 |
(destructor)0, |
|---|
| 522 |
(printfunc)0, |
|---|
| 523 |
(getattrfunc)0, |
|---|
| 524 |
(setattrfunc)0, |
|---|
| 525 |
(cmpfunc)0, |
|---|
| 526 |
(reprfunc)0, |
|---|
| 527 |
(PyNumberMethods*)0, |
|---|
| 528 |
(PySequenceMethods*)0, |
|---|
| 529 |
(PyMappingMethods*)0, |
|---|
| 530 |
(hashfunc)0, |
|---|
| 531 |
(ternaryfunc)0, |
|---|
| 532 |
(reprfunc)0, |
|---|
| 533 |
(getattrofunc)0, |
|---|
| 534 |
(setattrofunc)0, |
|---|
| 535 |
(PyBufferProcs*)0, |
|---|
| 536 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, |
|---|
| 537 |
"MidgardCollector", |
|---|
| 538 |
(traverseproc)0, |
|---|
| 539 |
(inquiry)0, |
|---|
| 540 |
(richcmpfunc)0, |
|---|
| 541 |
offsetof(PyGObject, weakreflist), |
|---|
| 542 |
(getiterfunc)0, |
|---|
| 543 |
(iternextfunc)0, |
|---|
| 544 |
pymidgard_collector_methods, |
|---|
| 545 |
(struct PyMemberDef*)0, |
|---|
| 546 |
(struct PyGetSetDef*)0, |
|---|
| 547 |
NULL, |
|---|
| 548 |
NULL, |
|---|
| 549 |
(descrgetfunc)0, |
|---|
| 550 |
(descrsetfunc)0, |
|---|
| 551 |
offsetof(PyGObject, inst_dict), |
|---|
| 552 |
(initproc)__collector_constructor, |
|---|
| 553 |
(allocfunc)0, |
|---|
| 554 |
(newfunc)0, |
|---|
| 555 |
(freefunc)0, |
|---|
| 556 |
(inquiry)0 |
|---|
| 557 |
}; |
|---|
| 558 |
|
|---|
| 559 |
void py_midgard_collector_register_class( |
|---|
| 560 |
PyObject *d, gpointer ot) |
|---|
| 561 |
{ |
|---|
| 562 |
pygobject_register_class(d, |
|---|
| 563 |
"collector", |
|---|
| 564 |
MIDGARD_TYPE_COLLECTOR, |
|---|
| 565 |
&Pymidgard_collector_Type, NULL); |
|---|
| 566 |
|
|---|
| 567 |
|
|---|
| 568 |
} |
|---|
| 569 |
|
|---|
| 570 |
PyTypeObject py_midgard_collector_get_type_object(void) |
|---|
| 571 |
{ |
|---|
| 572 |
return Pymidgard_collector_Type; |
|---|
| 573 |
} |
|---|
| 574 |
|
|---|