add dict constructor of flags for implicit convertion back

This commit is contained in:
Christopher Lackner 2024-05-31 13:23:53 +02:00
parent 3029b5422a
commit 3bb804eeaf

View File

@ -149,6 +149,12 @@ PYBIND11_MODULE(pyngcore, m) // NOLINT
py::class_<Flags>(m, "Flags")
.def(py::init<>())
.def("__str__", &ToString<Flags>)
.def(py::init([](py::dict kwargs) {
Flags flags;
for (auto d : kwargs)
SetFlag(flags, d.first.cast<string>(), d.second.cast<py::object>());
return flags;
}), "Create flags from dict")
.def(py::init([](py::kwargs kwargs) {
Flags flags;
for (auto d : kwargs)