diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2024-07-20 15:30:09 -0700 |
|---|---|---|
| committer | Donald Sharp <sharpd@nvidia.com> | 2024-07-31 08:08:53 -0400 |
| commit | 7fb8729a32e53a11f5cb0c5c741a35c59f33a273 (patch) | |
| tree | 024f1b00991beefe1ec8608c81211bf56c99ddb5 /lib/command_py.c | |
| parent | cf37c79f3132285a7d02f54573b1cfa85cb6b919 (diff) | |
lib/clippy: allow creating empty graph
When merging graphs, it makes sense to allow starting with an empty one.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/command_py.c')
| -rw-r--r-- | lib/command_py.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/command_py.c b/lib/command_py.c index ccdbfc5f8e..ada0f0d386 100644 --- a/lib/command_py.c +++ b/lib/command_py.c @@ -296,7 +296,7 @@ static PyObject *graph_parse(PyTypeObject *type, PyObject *args, PyObject *kwds) if (!gwrap) return NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|s", (char **)kwnames, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "z|s", (char **)kwnames, &def, &doc)) return NULL; @@ -304,12 +304,18 @@ static PyObject *graph_parse(PyTypeObject *type, PyObject *args, PyObject *kwds) struct cmd_token *token = cmd_token_new(START_TKN, 0, NULL, NULL); graph_new_node(graph, token, (void (*)(void *)) & cmd_token_del); - struct cmd_element cmd = {.string = def, .doc = doc}; - cmd_graph_parse(graph, &cmd); - cmd_graph_names(graph); + if (def) { + struct cmd_element cmd = { .string = def, .doc = doc }; + + cmd_graph_parse(graph, &cmd); + cmd_graph_names(graph); + + gwrap->definition = strdup(def); + } else { + gwrap->definition = strdup("NULL"); + } gwrap->graph = graph; - gwrap->definition = strdup(def); return (PyObject *)gwrap; } |
