| 1518 | } |
| 1519 | |
| 1520 | bool has_capability(const std::string& name) { |
| 1521 | ensure_initialized(); |
| 1522 | ensure_plugins_loaded(); |
| 1523 | const GilAcquire gil; |
| 1524 | bool result = false; |
| 1525 | |
| 1526 | PyObject* lfs_plugins = PyImport_ImportModule("lfs_plugins"); |
| 1527 | if (lfs_plugins) { |
| 1528 | PyObject* registry_class = PyObject_GetAttrString(lfs_plugins, "CapabilityRegistry"); |
| 1529 | if (registry_class) { |
| 1530 | PyObject* instance_method = PyObject_GetAttrString(registry_class, "instance"); |
| 1531 | PyObject* registry = PyObject_CallNoArgs(instance_method); |
| 1532 | if (registry) { |
| 1533 | PyObject* has_method = PyObject_GetAttrString(registry, "has"); |
| 1534 | PyObject* py_name = PyUnicode_FromString(name.c_str()); |
| 1535 | PyObject* py_result = PyObject_CallOneArg(has_method, py_name); |
| 1536 | if (py_result) { |
| 1537 | result = PyObject_IsTrue(py_result); |
| 1538 | Py_DECREF(py_result); |
| 1539 | } |
| 1540 | Py_DECREF(py_name); |
| 1541 | Py_DECREF(has_method); |
| 1542 | Py_DECREF(registry); |
| 1543 | } |
| 1544 | Py_DECREF(instance_method); |
| 1545 | Py_DECREF(registry_class); |
| 1546 | } |
| 1547 | Py_DECREF(lfs_plugins); |
| 1548 | } |
| 1549 | |
| 1550 | return result; |
| 1551 | } |
| 1552 | |
| 1553 | std::vector<CapabilityInfo> list_capabilities() { |
| 1554 | std::vector<CapabilityInfo> result; |
nothing calls this directly
no test coverage detected