Base: fix handling of path separators in parameter group names

This commit is contained in:
wmayer
2022-03-29 14:54:03 +02:00
parent 7c24e54704
commit b47029998e
3 changed files with 96 additions and 64 deletions

View File

@@ -98,6 +98,7 @@ public:
Py::Object repr();
Py::Object getGroup(const Py::Tuple&);
Py::Object getGroupName(const Py::Tuple&);
Py::Object getGroups(const Py::Tuple&);
Py::Object remGroup(const Py::Tuple&);
Py::Object hasGroup(const Py::Tuple&);
@@ -159,6 +160,7 @@ void ParameterGrpPy::init_type()
behaviors().readyType();
add_varargs_method("GetGroup",&ParameterGrpPy::getGroup,"GetGroup(str)");
add_varargs_method("GetGroupName",&ParameterGrpPy::getGroupName,"GetGroupName()");
add_varargs_method("GetGroups",&ParameterGrpPy::getGroups,"GetGroups()");
add_varargs_method("RemGroup",&ParameterGrpPy::remGroup,"RemGroup(str)");
add_varargs_method("HasGroup",&ParameterGrpPy::hasGroup,"HasGroup(str)");
@@ -260,17 +262,33 @@ Py::Object ParameterGrpPy::getGroup(const Py::Tuple& args)
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
throw Py::Exception();
try {
// get the Handle of the wanted group
Base::Reference<ParameterGrp> handle = _cParamGrp->GetGroup(pstr);
if (handle.isValid()) {
// create a python wrapper class
ParameterGrpPy *pcParamGrp = new ParameterGrpPy(handle);
// increment the ref count
return Py::asObject(pcParamGrp);
}
else {
throw Py::RuntimeError("GetGroup failed");
}
}
catch (const Base::Exception& e) {
e.setPyException();
throw Py::Exception();
}
}
Py::Object ParameterGrpPy::getGroupName(const Py::Tuple& args)
{
if (!PyArg_ParseTuple(args.ptr(), ""))
throw Py::Exception();
// get the Handle of the wanted group
Base::Reference<ParameterGrp> handle = _cParamGrp->GetGroup(pstr);
if (handle.isValid()) {
// create a python wrapper class
ParameterGrpPy *pcParamGrp = new ParameterGrpPy(handle);
// increment the ref count
return Py::asObject(pcParamGrp);
}
else {
throw Py::RuntimeError("GetGroup failed");
}
std::string name = _cParamGrp->GetGroupName();
return Py::String(name);
}
Py::Object ParameterGrpPy::getGroups(const Py::Tuple& args)