]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib/clippy: wrap cmd_graph_merge via Graph.merge()
authorDavid Lamparter <equinox@opensourcerouting.org>
Sat, 20 Jul 2024 22:36:20 +0000 (15:36 -0700)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 31 Jul 2024 12:08:53 +0000 (08:08 -0400)
Export cmd_graph_merge() to python code via graph1.merge(graph2).

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/command_py.c

index ada0f0d38609e4f479a465fa035c537d1f3117c6..82ca5a8ffcd09127bbbad7605a1a28a0af76ce71 100644 (file)
@@ -258,9 +258,13 @@ static PyObject *graph_first(PyObject *self, PyObject *args)
        return graph_to_pyobj(gwrap, gn);
 };
 
+static PyObject *graph_merge(PyObject *self, PyObject *args);
+
 static PyMethodDef methods_graph[] = {
-       {"first", graph_first, METH_NOARGS, "first graph node"},
-       {}};
+       { "first", graph_first, METH_NOARGS, "first graph node" },
+       { "merge", graph_merge, METH_VARARGS, "merge graphs" },
+       {}
+};
 
 static PyObject *graph_parse(PyTypeObject *type, PyObject *args,
                             PyObject *kwds);
@@ -285,6 +289,20 @@ static PyTypeObject typeobj_graph = {
        .tp_methods = methods_graph,
 };
 
+static PyObject *graph_merge(PyObject *self, PyObject *args)
+{
+       PyObject *py_other;
+       struct wrap_graph *gwrap = (struct wrap_graph *)self;
+       struct wrap_graph *gother;
+
+       if (!PyArg_ParseTuple(args, "O!", &typeobj_graph, &py_other))
+               return NULL;
+
+       gother = (struct wrap_graph *)py_other;
+       cmd_graph_merge(gwrap->graph, gother->graph, +1);
+       Py_RETURN_NONE;
+}
+
 /* top call / entrypoint for python code */
 static PyObject *graph_parse(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {