App: Improve Document.copyObject Python API.

This updates the `Document.copyObject` Python API by allowing for
keyword arguments and aligning the documentation with the C++ API.

This can make the Python code more readable, by using the keywords form:

```python
document.copyObject(obj, recursive=True, return_all=False)
```

Previous keyword-less version tested and still working for backwards
compatibility.
This commit is contained in:
tritao
2025-02-05 00:17:59 +00:00
committed by Chris Hennes
parent aa76a63abf
commit d60358443e
2 changed files with 18 additions and 7 deletions

View File

@@ -426,10 +426,21 @@ PyObject* DocumentPy::removeObject(PyObject* args)
}
}
PyObject* DocumentPy::copyObject(PyObject* args)
PyObject* DocumentPy::copyObject(PyObject* args, PyObject* kwd)
{
PyObject *obj, *rec = Py_False, *retAll = Py_False;
if (!PyArg_ParseTuple(args, "O|O!O!", &obj, &PyBool_Type, &rec, &PyBool_Type, &retAll)) {
PyObject* obj;
PyObject* rec = Py_False;
PyObject* retAll = Py_False;
static constexpr std::array<const char*, 4> kwlist {"object", "recursive", "return_all", nullptr};
if (!Base::Wrapped_ParseTupleAndKeywords(args,
kwd,
"O|O!O!",
kwlist,
&obj,
&PyBool_Type,
&rec,
&PyBool_Type,
&retAll)) {
return nullptr;
}