1 /* -*- Mode: C; c-basic-offset: 4 -*- */
7 #define NO_IMPORT_PYGOBJECT
10 #include <beagle/beagle.h>
12 #define BEAGLE_TYPE_HIT (beagle_hit_get_gtype ())
13 #define BEAGLE_TYPE_PROPERTY (beagle_property_get_gtype ())
14 #define BEAGLE_TYPE_TIMESTAMP (beagle_timestamp_get_gtype ())
15 #define BEAGLE_TYPE_QUERYABLE_STATUS (beagle_queryable_status_get_gtype ())
16 #define BEAGLE_TYPE_SCHEDULER_INFORMATION (beagle_scheduler_information_get_gtype ())
19 beagle_hit_get_gtype (void)
21 static GType our_type = 0;
23 our_type = g_pointer_type_register_static ("BeagleHit");
28 beagle_timestamp_get_gtype (void)
30 static GType our_type = 0;
32 our_type = g_pointer_type_register_static ("BeagleTimestamp");
37 beagle_property_get_gtype (void)
39 static GType our_type = 0;
41 our_type = g_pointer_type_register_static ("BeagleProperty");
46 beagle_queryable_status_get_gtype (void)
48 static GType our_type = 0;
50 our_type = g_pointer_type_register_static ("BeagleQueryableStatus");
55 beagle_scheduler_information_get_gtype (void)
57 static GType our_type = 0;
59 our_type = g_pointer_type_register_static ("BeagleSchedulerInformation");
64 _helper_wrap_pointer_gslist (GType type, GSList *list)
69 if ((py_list = PyList_New(0)) == NULL) {
72 for (tmp = list; tmp != NULL; tmp = tmp->next) {
73 PyObject *obj = pyg_pointer_new (type, tmp->data);
74 PyList_Append(py_list, obj);
81 _helper_wrap_string_gslist (GSList *list)
86 if ((py_list = PyList_New(0)) == NULL) {
89 for (tmp = list; tmp != NULL; tmp = tmp->next) {
90 PyObject *str_obj = PyString_FromString ((char*)tmp->data);
92 if (str_obj == NULL) {
96 PyList_Append(py_list, str_obj);
104 import gobject.GObject as PyGObject_Type
107 beagle_snippet_request_set_query_terms_from_query
109 override beagle_hits_added_response_get_hits noargs
111 _wrap_beagle_hits_added_response_get_hits(PyGObject *self)
115 list = beagle_hits_added_response_get_hits(BEAGLE_HITS_ADDED_RESPONSE (self->obj));
117 return _helper_wrap_pointer_gslist (BEAGLE_TYPE_HIT, list);
120 override beagle_hits_subtracted_response_get_uris noargs
122 _wrap_beagle_hits_subtracted_response_get_uris(PyGObject *self)
126 list = beagle_hits_subtracted_response_get_uris(BEAGLE_HITS_SUBTRACTED_RESPONSE (self->obj));
128 return _helper_wrap_string_gslist (list);
131 override beagle_hit_get_one_property kwargs
133 _wrap_beagle_hit_get_one_property (PyGObject *self, PyObject *args, PyObject *kwargs)
135 static char *kwlist[] = { "key", NULL };
137 const char *value = NULL;
140 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:BeagleHit.get_one_property", kwlist, &key))
142 ret = beagle_hit_get_one_property (pyg_pointer_get (self, BeagleHit), key, &value);
145 /* Dont return exception in the method case */
150 return PyString_FromString (value);
153 override beagle_hit_get_properties kwargs
155 _wrap_beagle_hit_get_properties (PyGObject *self, PyObject *args, PyObject *kwargs)
157 static char *kwlist[] = { "key", NULL };
161 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:BeagleHit.get_properties", kwlist, &key))
163 list = beagle_hit_get_properties (pyg_pointer_get(self, BeagleHit), key);
166 return _helper_wrap_string_gslist (list);
172 override beagle_hit_get_all_properties noargs
174 _wrap_beagle_hit_get_all_properties (PyGObject *self)
178 list = beagle_hit_get_all_properties ((BeagleHit *) self->obj);
180 return _helper_wrap_pointer_gslist (BEAGLE_TYPE_PROPERTY, list);
183 override-slot BeagleHit.tp_as_mapping
185 _wrap_beagle_hit_get_one_property_mapping (PyGObject *self, PyObject *item)
188 const char *value = NULL;
191 if (! PyString_Check (item)) {
192 PyErr_SetString(PyExc_TypeError, "key must be a string");
196 key = PyString_AsString (item);
197 ret = beagle_hit_get_one_property ((BeagleHit *) self->obj, key, &value);
200 PyErr_SetString(PyExc_KeyError, "key doesnt exist or is not single valued");
204 return PyString_FromString (value);
208 static PyMappingMethods _wrap_beagle_hit_tp_as_mapping = {
209 (inquiry) 0, /* number of properties as len (hit) */
210 (binaryfunc) _wrap_beagle_hit_get_one_property_mapping, /* getting value of property as hit [...] */
211 (objobjargproc) 0 /* for setting value of property as hit[...] = X*/
214 override beagle_client_new kwargs
216 _wrap_beagle_client_new(PyGObject *self, PyObject *args, PyObject *kwargs)
218 static char *kwlist[] = { "client_name", NULL };
219 char *client_name = NULL;
221 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s:BeagleClient.__init__", kwlist, &client_name))
223 self->obj = (GObject *)beagle_client_new(client_name);
226 PyErr_SetString(PyExc_RuntimeError, "could not create BeagleClient object");
229 pygobject_register_wrapper((PyObject *)self);
233 override beagle_timestamp_to_unix_time
235 _wrap_beagle_timestamp_to_unix_time (PyGObject *self)
240 ret = beagle_timestamp_to_unix_time ((BeagleTimestamp *) self->obj, &t);
243 PyErr_SetString(PyExc_ValueError, "timestamp is invalid");
247 return PyInt_FromLong (t);
250 override beagle_scheduler_information_get_pending_tasks noargs
252 _wrap_beagle_scheduler_information_get_pending_tasks (PyGObject *self)
256 list = beagle_scheduler_information_get_pending_tasks ((BeagleSchedulerInformation *) self->obj);
258 return _helper_wrap_string_gslist (list);
261 override beagle_scheduler_information_get_future_tasks noargs
263 _wrap_beagle_scheduler_information_get_future_tasks (PyGObject *self)
267 list = beagle_scheduler_information_get_future_tasks ((BeagleSchedulerInformation *) self->obj);
269 return _helper_wrap_string_gslist (list);
272 override beagle_scheduler_information_get_blocked_tasks noargs
274 _wrap_beagle_scheduler_information_get_blocked_tasks (PyGObject *self)
278 list = beagle_scheduler_information_get_blocked_tasks ((BeagleSchedulerInformation *) self->obj);
280 return _helper_wrap_string_gslist (list);
283 override beagle_daemon_information_response_get_index_status
285 _wrap_beagle_daemon_information_response_get_index_status (PyGObject *self)
289 list = beagle_daemon_information_response_get_index_status ((BeagleDaemonInformationResponse *) self->obj);
291 return _helper_wrap_pointer_gslist (BEAGLE_TYPE_QUERYABLE_STATUS, list);