diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2020-01-04 13:54:17 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2020-01-04 13:54:17 (GMT) |
commit | 4b54747c0ee3736591b3fb38b156837b0958b1cc (patch) | |
tree | 618a8454446f4f8f25aa5f7817c72bbcc706ae4d /plugins/yaml/python/node.c | |
parent | aded4e75efc21319d5a777bf53bc087587f0740c (diff) |
Stuck to the Yaml specifications a little bit more.
Diffstat (limited to 'plugins/yaml/python/node.c')
-rw-r--r-- | plugins/yaml/python/node.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/plugins/yaml/python/node.c b/plugins/yaml/python/node.c index 31daa04..2951f0f 100644 --- a/plugins/yaml/python/node.c +++ b/plugins/yaml/python/node.c @@ -52,6 +52,9 @@ static PyObject *py_yaml_node_find_by_path(PyObject *, PyObject *); /* Recherche l'unique noeud correspondant à un chemin. */ static PyObject *py_yaml_node_find_one_by_path(PyObject *, PyObject *); +/* Fournit la ligne d'origine associée à un noeud. */ +static PyObject *py_yaml_node_get_yaml_line(PyObject *, void *); + /****************************************************************************** @@ -189,6 +192,51 @@ static PyObject *py_yaml_node_find_one_by_path(PyObject *self, PyObject *args) /****************************************************************************** * * +* Paramètres : self = objet Python concerné par l'appel. * +* closure = non utilisé ici. * +* * +* Description : Fournit la ligne principale associée à un noeud. * +* * +* Retour : Ligne Yaml à l'origine du noeud. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_yaml_node_get_yaml_line(PyObject *self, void *closure) +{ + PyObject *result; /* Résultat à retourner */ + GYamlNode *node; /* Version GLib du noeud */ + GYamlLine *line; /* Line Yaml associée */ + +#define YAML_NODE_YAML_LINE_ATTRIB PYTHON_GET_DEF_FULL \ +( \ + yaml_line, py_yaml_node, \ + "Orginal Yaml line linked to the node." \ +) + + node = G_YAML_NODE(pygobject_get(self)); + + line = g_yaml_node_get_yaml_line(node); + + if (line == NULL) + { + result = Py_None; + Py_INCREF(result); + } + else + { + result = pygobject_new(G_OBJECT(line)); + g_object_unref(G_OBJECT(line)); + } + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : - * * * * Description : Fournit un accès à une définition de type à diffuser. * @@ -208,6 +256,7 @@ PyTypeObject *get_python_yaml_node_type(void) }; static PyGetSetDef py_yaml_node_getseters[] = { + YAML_NODE_YAML_LINE_ATTRIB, { NULL } }; |