| 315 | } |
| 316 | |
| 317 | PyObject* PropertyContainerPy::getPropertyStatus(PyObject* args) |
| 318 | { |
| 319 | const char* name = ""; |
| 320 | if (!PyArg_ParseTuple(args, "|s", &name)) { |
| 321 | return nullptr; |
| 322 | } |
| 323 | |
| 324 | Py::List ret; |
| 325 | const auto& statusMap = getStatusMap(); |
| 326 | if (!name[0]) { |
| 327 | for (auto& v : statusMap) { |
| 328 | ret.append(Py::String(v.first.c_str())); |
| 329 | } |
| 330 | } |
| 331 | else { |
| 332 | App::Property* prop = getPropertyContainerPtr()->getPropertyByName(name); |
| 333 | if (!prop) { |
| 334 | PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", name); |
| 335 | return nullptr; |
| 336 | } |
| 337 | |
| 338 | auto linkProp = freecad_cast<App::PropertyLinkBase*>(prop); |
| 339 | if (linkProp && linkProp->testFlag(App::PropertyLinkBase::LinkAllowPartial)) { |
| 340 | ret.append(Py::String("AllowPartial")); |
| 341 | } |
| 342 | |
| 343 | std::bitset<32> bits(prop->getStatus()); |
| 344 | for (size_t i = 1; i < bits.size(); ++i) { |
| 345 | if (!bits[i]) { |
| 346 | continue; |
| 347 | } |
| 348 | bool found = false; |
| 349 | for (auto& v : statusMap) { |
| 350 | if (v.second == static_cast<int>(i)) { |
| 351 | ret.append(Py::String(v.first.c_str())); |
| 352 | found = true; |
| 353 | break; |
| 354 | } |
| 355 | } |
| 356 | if (!found) { |
| 357 | ret.append(Py::Long(static_cast<long>(i))); |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | return Py::new_reference_to(ret); |
| 362 | } |
| 363 | |
| 364 | PyObject* PropertyContainerPy::getEditorMode(PyObject* args) |
| 365 | { |
no test coverage detected