What problem does it solves?
Developing robust, extensible plugin systems that seamlessly integrate Python with C++ can be a significant architectural challenge, involving complex bindings, event handling, and lifecycle management. This Skill simplifies the creation and management of Python plugins for C++ applications, enabling rapid feature expansion and customization without deep expertise in inter-language communication.
Core Features & Use Cases
- Extension Point Implementation: Guide the creation of C++ Extension Points and their Python implementations using
pybind11, bridging your core application with dynamic features.
- Event-Driven Architecture: Design and utilize the Event Bus for asynchronous, thread-safe communication between core and plugins, ensuring responsive and stable interactions.
.kplugin Format Management: Structure, validate, and load plugins packaged in the .kplugin (ZIP) format with manifest.json, streamlining distribution and deployment.
- Use Case: Develop a new "Advanced Analytics" plugin in Python that integrates with Kalahari's core C++ data models, leveraging the Event Bus to react to document changes and
pybind11 to expose custom analysis functions to the UI, all while maintaining a clean separation of concerns.
Quick Start
Example: Basic Python plugin entry point
from kalahari import IExporter, event_bus
class MyExporter(IExporter):
def get_file_extension(self) -> str:
return "txt"
def get_format_name(self) -> str:
return "Plain Text"
def export_document(self, document, file_path: str) -> bool:
with open(file_path, 'w') as f:
f.write(document.get_content())
return True
def plugin_init(kalahari_api):
exporter = MyExporter()
kalahari_api.register_exporter(exporter)
event_bus.subscribe("document.saved", lambda data: print(f"Doc saved: {data}"))