|
@@ -135,28 +135,14 @@ Graph_init (GraphObject *self, PyObject *args, PyObject *kwargs)
|
|
{
|
|
{
|
|
unsigned char store_type;
|
|
unsigned char store_type;
|
|
PyObject *uri_obj = NULL;
|
|
PyObject *uri_obj = NULL;
|
|
- LSUP_Term *uri = NULL, *src_uri = NULL;
|
|
|
|
|
|
+ char *uri_str = NULL;
|
|
|
|
|
|
- static char *kwlist[] = {"", "uri_obj", NULL};
|
|
|
|
|
|
+ static char *kwlist[] = {"", "uri_str", NULL};
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords (
|
|
if (!PyArg_ParseTupleAndKeywords (
|
|
- args, kwargs, "b|O", kwlist, &store_type, &uri_obj))
|
|
|
|
|
|
+ args, kwargs, "b|s", kwlist, &store_type, &uri_str))
|
|
return -1;
|
|
return -1;
|
|
|
|
|
|
- if (uri_obj) {
|
|
|
|
- if (!PyObject_TypeCheck (uri_obj, &TermType)) {
|
|
|
|
- PyErr_SetString (PyExc_TypeError, "uri is not a Term type.");
|
|
|
|
- return -1;
|
|
|
|
- }
|
|
|
|
- src_uri = ((TermObject *) uri_obj)->ob_struct;
|
|
|
|
- uri = LSUP_iriref_new (src_uri->data, LSUP_iriref_nsm (src_uri));
|
|
|
|
- if (! LSUP_IS_IRI (uri)) {
|
|
|
|
- PyErr_SetString (PyExc_TypeError, "uri is not a IRIREF type.");
|
|
|
|
- return -1;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// Set up the store if a function for that is defined.
|
|
// Set up the store if a function for that is defined.
|
|
const LSUP_StoreInt *sif = LSUP_store_int (store_type);
|
|
const LSUP_StoreInt *sif = LSUP_store_int (store_type);
|
|
if (UNLIKELY (!sif)) {
|
|
if (UNLIKELY (!sif)) {
|
|
@@ -177,12 +163,12 @@ Graph_init (GraphObject *self, PyObject *args, PyObject *kwargs)
|
|
}
|
|
}
|
|
|
|
|
|
// TODO Make store ID, nsm and initial size accessible.
|
|
// TODO Make store ID, nsm and initial size accessible.
|
|
- self->ob_struct = LSUP_graph_new (store, uri, NULL);
|
|
|
|
|
|
+ self->ob_struct = LSUP_graph_new (store, uri_str, NULL);
|
|
if (!self->ob_struct) {
|
|
if (!self->ob_struct) {
|
|
PyErr_SetString (PyExc_ValueError, "Could not create graph.");
|
|
PyErr_SetString (PyExc_ValueError, "Could not create graph.");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
- if (uri) LSUP_term_free (uri);
|
|
|
|
|
|
+ if (uri_str) free (uri_str);
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -207,16 +193,13 @@ Graph_get_uri (GraphObject *self, void *closure)
|
|
|
|
|
|
|
|
|
|
static int
|
|
static int
|
|
-Graph_set_uri (GraphObject *self, PyObject *value, void *closure)
|
|
|
|
|
|
+Graph_set_uri (GraphObject *self, PyObject *args)
|
|
{
|
|
{
|
|
- if (!PyObject_TypeCheck (value, &TermType)) {
|
|
|
|
- PyErr_SetString (PyExc_TypeError, "URI is not a Term type.");
|
|
|
|
- return -1;
|
|
|
|
- }
|
|
|
|
- LSUP_Term *gr_uri = ((TermObject*)value)->ob_struct;
|
|
|
|
- LOG_DEBUG("New graph URI: %s", (gr_uri->data));
|
|
|
|
|
|
+ char *uri_str = NULL;
|
|
|
|
+ if (! PyArg_ParseTuple (args, "s", &uri_str)) return NULL;
|
|
|
|
|
|
- LSUP_rc rc = LSUP_graph_set_uri (self->ob_struct, LSUP_term_copy (gr_uri));
|
|
|
|
|
|
+ LSUP_rc rc = LSUP_graph_set_uri (self->ob_struct, uri_str);
|
|
|
|
+ free (uri_str);
|
|
|
|
|
|
return rc == LSUP_OK ? 0 : -1;
|
|
return rc == LSUP_OK ? 0 : -1;
|
|
}
|
|
}
|