Skip to content

Commit

Permalink
[python] Interface 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelSchneid3r committed Nov 18, 2024
1 parent cdbb0e6 commit dc00273
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.16)
find_package(Albert REQUIRED)

project(python VERSION 4.11)
project(python VERSION 4.12)

set(PYBIND11_FINDPYTHON ON)
#find_package(Python 3.8 COMPONENTS Interpreter Development REQUIRED)
Expand Down
24 changes: 20 additions & 4 deletions python/albert.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
# Albert Python interface v2.4
# Albert Python interface v2.5
The Python interface is a subset of the internal C++ interface exposed to Python with some minor adjustments. A Python
Expand Down Expand Up @@ -78,6 +78,12 @@ Changes in 2.4:
- Deprecate parameter `workdir` of runTerminal. Prepend `cd <workdir>;` to your script.
- Deprecate parameter `close_on_exit` of runTerminal. Append `exec $SHELL;` to your script.
Changes in 2.5:
- Matcher now not considered experimental anymore.
- Add `Matcher.match(strings: List[str])`.
- Add `Matcher.match(*args: str)`.
## List of things 3.0 will break
- Drop PluginInstance.initialize. Use PluginInstance.__init__(…).
Expand Down Expand Up @@ -376,6 +382,12 @@ class FallbackHandler(Extension):
class Query():
"""https://albertlauncher.github.io/reference/classalbert_1_1Query.html"""

def __str__(self) -> str:
"""
Returns the query string.
Since 2.5
"""

@property
def trigger(self) -> str:
...
Expand Down Expand Up @@ -550,12 +562,16 @@ class Matcher:
...

@overload
def match(self, item: Item) -> Match:
def match(self, string: str) -> Match:
"""Since 2.3"""

@overload
def match(self, string: str) -> Match:
"""Since 2.3"""
def match(self, strings: List[str]) -> Match:
"""Since 2.5"""

@overload
def match(self, *args: str) -> Match:
"""Since 2.5"""


def debug(arg: Any):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins
3 changes: 2 additions & 1 deletion python/src/embeddedmodule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ PYBIND11_EMBEDDED_MODULE(albert, m)

py::class_<Matcher>(m, "Matcher")
.def(py::init<const QString&>())
.def("match", static_cast<Match(Matcher::*)(const Item&) const>(&Matcher::match))
.def("match", static_cast<Match(Matcher::*)(const QString&) const>(&Matcher::match))
.def("match", static_cast<Match(Matcher::*)(const QStringList&) const>(&Matcher::match))
.def("match", [](Matcher *self, py::args args){ return self->match(py::cast<QStringList>(args)); });
;

// ------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion python/src/pypluginloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class PyPluginLoader : public albert::PluginLoader
public:

static const int MAJOR_INTERFACE_VERSION = 2;
static const int MINOR_INTERFACE_VERSION = 4;
static const int MINOR_INTERFACE_VERSION = 5;

PyPluginLoader(Plugin &plugin, const QString &module_path);
~PyPluginLoader();
Expand Down

0 comments on commit dc00273

Please sign in to comment.