pyflowlauncher 0.6.2.dev0__tar.gz → 0.7.1.dev0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/PKG-INFO +4 -2
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/README.md +3 -1
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher/__init__.py +0 -9
- pyflowlauncher-0.7.1.dev0/pyflowlauncher/event.py +34 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher/plugin.py +19 -10
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher.egg-info/PKG-INFO +4 -2
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyproject.toml +2 -2
- pyflowlauncher-0.6.2.dev0/pyflowlauncher/event.py +0 -29
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/LICENSE +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher/api.py +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher/icons.py +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher/jsonrpc.py +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher/manifest.py +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher/method.py +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher/py.typed +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher/result.py +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher/settings.py +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher/shared.py +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher/string_matcher.py +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher/utils.py +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher.egg-info/SOURCES.txt +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher.egg-info/dependency_links.txt +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher.egg-info/requires.txt +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher.egg-info/top_level.txt +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/setup.cfg +0 -0
- {pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyflowlauncher
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.1.dev0
|
|
4
4
|
Summary: Python library to help build Flow Launcher plugins.
|
|
5
5
|
Author-email: William McAllister <dev.garulf@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -26,9 +26,11 @@ pyFlowLauncher is an API that allows you to quickly create plugins for Flow Laun
|
|
|
26
26
|
Install via pip:
|
|
27
27
|
|
|
28
28
|
```py
|
|
29
|
-
python -m pip install pyflowlauncher
|
|
29
|
+
python -m pip install pyflowlauncher[all]
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
> ⚠️ The `[all]` is important if you intend to support Python versions older then `3.11`.
|
|
33
|
+
|
|
32
34
|
## Usage
|
|
33
35
|
|
|
34
36
|
### Basic plugin
|
|
@@ -12,9 +12,11 @@ pyFlowLauncher is an API that allows you to quickly create plugins for Flow Laun
|
|
|
12
12
|
Install via pip:
|
|
13
13
|
|
|
14
14
|
```py
|
|
15
|
-
python -m pip install pyflowlauncher
|
|
15
|
+
python -m pip install pyflowlauncher[all]
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
> ⚠️ The `[all]` is important if you intend to support Python versions older then `3.11`.
|
|
19
|
+
|
|
18
20
|
## Usage
|
|
19
21
|
|
|
20
22
|
### Basic plugin
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import importlib.metadata
|
|
2
2
|
import logging
|
|
3
|
-
import os
|
|
4
3
|
|
|
5
4
|
from .plugin import Plugin
|
|
6
5
|
from .result import JsonRPCAction, Result, send_results, ResultResponse
|
|
7
6
|
from .method import Method
|
|
8
7
|
|
|
9
|
-
log_level = os.environ.get("FLOW_LAUNCHER_API_LOG_LEVEL", "INFO")
|
|
10
8
|
|
|
11
9
|
logger = logging.getLogger(__name__)
|
|
12
10
|
|
|
@@ -22,10 +20,3 @@ __all__ = [
|
|
|
22
20
|
"JsonRPCAction",
|
|
23
21
|
"Method",
|
|
24
22
|
]
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
logging.basicConfig(
|
|
28
|
-
level=log_level,
|
|
29
|
-
format="%(asctime)s <%(name)s>[%(levelname)s]: %(message)s",
|
|
30
|
-
datefmt="%Y-%m-%d %H:%M:%S",
|
|
31
|
-
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
from typing import Any, Callable, Iterable, Type
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class EventHandler:
|
|
7
|
+
|
|
8
|
+
def __init__(self):
|
|
9
|
+
self._methods = {}
|
|
10
|
+
self._handlers = {}
|
|
11
|
+
|
|
12
|
+
def _get_callable_name(self, method: Callable[..., Any]):
|
|
13
|
+
return getattr(method, '__name__', method.__class__.__name__).lower()
|
|
14
|
+
|
|
15
|
+
def add_method(self, method: Callable[..., Any], *, name=None) -> str:
|
|
16
|
+
key = name or self._get_callable_name(method)
|
|
17
|
+
self._methods[key] = method
|
|
18
|
+
return key
|
|
19
|
+
|
|
20
|
+
def add_methods(self, methods: Iterable[Callable[..., Any]]):
|
|
21
|
+
for method in methods:
|
|
22
|
+
self.add_method(method)
|
|
23
|
+
|
|
24
|
+
def add_exception_handler(self, exception: Type[Exception], handler: Callable[..., Any]):
|
|
25
|
+
self._handlers[exception] = handler
|
|
26
|
+
|
|
27
|
+
def __call__(self, method: str, *args, **kwargs):
|
|
28
|
+
try:
|
|
29
|
+
return self._methods[method](*args, **kwargs)
|
|
30
|
+
except Exception as e:
|
|
31
|
+
handler = self._handlers.get(type(e), None)
|
|
32
|
+
if handler:
|
|
33
|
+
return handler(e)
|
|
34
|
+
raise e
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import sys
|
|
4
4
|
from functools import wraps
|
|
5
|
-
from typing import Any, Callable, Iterable, Union
|
|
5
|
+
from typing import Any, Callable, Iterable, Optional, Type, Union
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
import json
|
|
8
8
|
|
|
@@ -26,11 +26,9 @@ class Plugin:
|
|
|
26
26
|
if methods:
|
|
27
27
|
self.add_methods(methods)
|
|
28
28
|
|
|
29
|
-
def add_method(self, method: Method) ->
|
|
29
|
+
def add_method(self, method: Method) -> str:
|
|
30
30
|
"""Add a method to the event handler."""
|
|
31
|
-
|
|
32
|
-
self._logger.debug(f"Adding method: '{name}'")
|
|
33
|
-
self._event_handler.add_method(method, name=name)
|
|
31
|
+
return self._event_handler.add_method(method)
|
|
34
32
|
|
|
35
33
|
def add_methods(self, methods: Iterable[Method]) -> None:
|
|
36
34
|
self._event_handler.add_methods(methods)
|
|
@@ -46,10 +44,22 @@ class Plugin:
|
|
|
46
44
|
"""Register a method to be called when the plugin is run."""
|
|
47
45
|
return self.on_method(method)
|
|
48
46
|
|
|
49
|
-
def add_exception_handler(self, exception: Exception, handler: Callable[..., Any]) -> None:
|
|
47
|
+
def add_exception_handler(self, exception: Type[Exception], handler: Callable[..., Any]) -> None:
|
|
50
48
|
"""Add exception handler to be called when an exception is raised in a method."""
|
|
51
49
|
self._event_handler.add_exception_handler(exception, handler)
|
|
52
50
|
|
|
51
|
+
def on_except(self, exception: Type[Exception]) -> Callable[..., Any]:
|
|
52
|
+
@wraps(exception)
|
|
53
|
+
def wrapper(handler: Callable[..., Any]) -> Callable[..., Any]:
|
|
54
|
+
self.add_exception_handler(exception, handler)
|
|
55
|
+
return handler
|
|
56
|
+
return wrapper
|
|
57
|
+
|
|
58
|
+
def action(self, method: Method, parameters: Optional[Iterable] = None) -> JsonRPCAction:
|
|
59
|
+
"""Register a method and return a JsonRPCAction that calls it."""
|
|
60
|
+
method_name = self.add_method(method)
|
|
61
|
+
return {"method": method_name, "parameters": parameters or []}
|
|
62
|
+
|
|
53
63
|
@property
|
|
54
64
|
def settings(self) -> dict:
|
|
55
65
|
if self._settings is None:
|
|
@@ -59,12 +69,11 @@ class Plugin:
|
|
|
59
69
|
|
|
60
70
|
def run(self) -> None:
|
|
61
71
|
request = self._client.recieve()
|
|
62
|
-
method = request
|
|
72
|
+
method = request["method"]
|
|
63
73
|
parameters = request.get('parameters', [])
|
|
64
74
|
feedback = self._event_handler(method, *parameters)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
feedback['SettingsChange'] = self.settings
|
|
75
|
+
if not feedback:
|
|
76
|
+
return
|
|
68
77
|
self._client.send(feedback)
|
|
69
78
|
|
|
70
79
|
@property
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyflowlauncher
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.1.dev0
|
|
4
4
|
Summary: Python library to help build Flow Launcher plugins.
|
|
5
5
|
Author-email: William McAllister <dev.garulf@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -26,9 +26,11 @@ pyFlowLauncher is an API that allows you to quickly create plugins for Flow Laun
|
|
|
26
26
|
Install via pip:
|
|
27
27
|
|
|
28
28
|
```py
|
|
29
|
-
python -m pip install pyflowlauncher
|
|
29
|
+
python -m pip install pyflowlauncher[all]
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
> ⚠️ The `[all]` is important if you intend to support Python versions older then `3.11`.
|
|
33
|
+
|
|
32
34
|
## Usage
|
|
33
35
|
|
|
34
36
|
### Basic plugin
|
|
@@ -6,7 +6,7 @@ name = "pyflowlauncher"
|
|
|
6
6
|
authors = [
|
|
7
7
|
{name = "William McAllister", email = "dev.garulf@gmail.com"}
|
|
8
8
|
]
|
|
9
|
-
version = '0.
|
|
9
|
+
version = '0.7.1-dev.0'
|
|
10
10
|
description = "Python library to help build Flow Launcher plugins."
|
|
11
11
|
readme = "README.md"
|
|
12
12
|
requires-python = ">=3.8"
|
|
@@ -30,7 +30,7 @@ packages = ["pyflowlauncher"]
|
|
|
30
30
|
"pyflowlauncher" = ["py.typed"]
|
|
31
31
|
|
|
32
32
|
[tool.bumpversion]
|
|
33
|
-
current_version = "0.
|
|
33
|
+
current_version = "0.7.1-dev.0"
|
|
34
34
|
parse = """(?x)
|
|
35
35
|
(?P<major>[0-9]+)
|
|
36
36
|
\\.(?P<minor>[0-9]+)
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
from typing import Any, Callable
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class EventHandler:
|
|
7
|
-
|
|
8
|
-
def __init__(self):
|
|
9
|
-
self._methods = {}
|
|
10
|
-
self._handlers = {}
|
|
11
|
-
|
|
12
|
-
def add_method(self, method, *, name=None):
|
|
13
|
-
self._methods[name or method.__name__] = method
|
|
14
|
-
|
|
15
|
-
def add_methods(self, methods):
|
|
16
|
-
for method in methods:
|
|
17
|
-
self.add_method(method)
|
|
18
|
-
|
|
19
|
-
def add_exception_handler(self, exception: Exception, handler: Callable[..., Any]):
|
|
20
|
-
self._handlers[exception.__class__.__name__] = handler
|
|
21
|
-
|
|
22
|
-
def __call__(self, method, *args, **kwargs):
|
|
23
|
-
try:
|
|
24
|
-
return self._methods[method](*args, **kwargs)
|
|
25
|
-
except Exception as e:
|
|
26
|
-
handler = self._handlers.get(e.__class__.__name__, None)
|
|
27
|
-
if handler:
|
|
28
|
-
return handler(e)
|
|
29
|
-
raise e
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher.egg-info/requires.txt
RENAMED
|
File without changes
|
{pyflowlauncher-0.6.2.dev0 → pyflowlauncher-0.7.1.dev0}/pyflowlauncher.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|