diff options
Diffstat (limited to 'plugins/yaml/python/collection.c')
-rw-r--r-- | plugins/yaml/python/collection.c | 71 |
1 files changed, 3 insertions, 68 deletions
diff --git a/plugins/yaml/python/collection.c b/plugins/yaml/python/collection.c index 7166784..e21bb9e 100644 --- a/plugins/yaml/python/collection.c +++ b/plugins/yaml/python/collection.c @@ -31,6 +31,7 @@ #include <plugins/pychrysalide/helpers.h> +#include "node.h" #include "../collection.h" @@ -38,9 +39,6 @@ /* Crée un nouvel objet Python de type 'YamlCollection'. */ static PyObject *py_yaml_collection_new(PyTypeObject *, PyObject *, PyObject *); -/* Recherche les noeuds correspondant à un chemin. */ -static PyObject *py_yaml_collection_find_by_path(PyObject *, PyObject *); - /* Indique la nature d'une collection Yaml. */ static PyObject *py_yaml_collection_is_sequence(PyObject *, void *); @@ -71,7 +69,7 @@ static PyObject *py_yaml_collection_new(PyTypeObject *type, PyObject *args, PyOb GYamlCollection *collec; /* Création GLib à transmettre */ #define YAML_COLLECTION_DOC \ - "YamlCollection handle a collection of Yaml nodes.\n" \ + "YamlCollection handles a collection of Yaml nodes.\n" \ "\n" \ "Instances can be created using the following constructor:\n" \ "\n" \ @@ -95,68 +93,6 @@ static PyObject *py_yaml_collection_new(PyTypeObject *type, PyObject *args, PyOb /****************************************************************************** * * -* Paramètres : self = variable non utilisée ici. * -* args = arguments fournis à l'appel. * -* * -* Description : Recherche les noeuds correspondant à un chemin. * -* * -* Retour : Liste de noeuds trouvés, éventuellement vide. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static PyObject *py_yaml_collection_find_by_path(PyObject *self, PyObject *args) -{ - PyObject *result; /* Instance à retourner */ - const char *path; /* Chemin d'accès à traiter */ - int ret; /* Bilan de lecture des args. */ - GYamlCollection *collec; /* Version GLib du type */ - GYamlNode **found; /* Créations GLib à transmettre*/ - size_t count; /* Quantité de trouvailles */ - size_t i; /* Boucle de parcours */ - -#define YAML_COLLECTION_FIND_BY_PATH PYTHON_METHOD_DEF \ -( \ - find_by_path, "path", \ - METH_VARARGS, py_yaml_collection, \ - "Find nodes from a Yaml node using a path.\n" \ - "\n" \ - "Paths are node keys separated by '/', such as '/my/path/to/node'." \ -) - - ret = PyArg_ParseTuple(args, "s", &path); - if (!ret) return NULL; - - collec = G_YAML_COLLEC(pygobject_get(self)); - - g_yaml_collection_find_by_path(collec, path, &found, &count); - - result = PyTuple_New(count); - - for (i = 0; i < count; i++) - { -#ifndef NDEBUG - ret = PyTuple_SetItem(result, i, pygobject_new(G_OBJECT(found[i]))); - assert(ret == 0); -#else - PyTuple_SetItem(result, i, pygobject_new(G_OBJECT(found[i]))); -#endif - - g_object_unref(G_OBJECT(found[i])); - - } - - if (found != NULL) - free(found); - - return result; - -} - - -/****************************************************************************** -* * * Paramètres : self = objet Python concerné par l'appel. * * closure = non utilisé ici. * * * @@ -264,7 +200,6 @@ static PyObject *py_yaml_collection_is_sequence(PyObject *self, void *closure) PyTypeObject *get_python_yaml_collection_type(void) { static PyMethodDef py_yaml_collection_methods[] = { - YAML_COLLECTION_FIND_BY_PATH, { NULL } }; @@ -317,7 +252,7 @@ bool register_python_yaml_collection(PyObject *module) dict = PyModule_GetDict(module); - if (!register_class_for_pygobject(dict, G_TYPE_YAML_COLLEC, type, &PyGObject_Type)) + if (!register_class_for_pygobject(dict, G_TYPE_YAML_COLLEC, type, get_python_yaml_node_type())) return false; return true; |