This package enables extension management.
Project description
Readme
About myrrh_core_exts
This package is part of the Myrrh project.
This package enables extension management. It aims to simplify the management and registration of myrrh extensions by using URI.
Baseline:earendel.
Requirements
- Python >= 3.12
Installation
To install myrrh-exts, simply execute:
$ pip install myrrh-core-exts
Getting Started
Myrrh core extension package is based on URI, predefined interfaces, and the standard entry point mechanism.
How to define a myrrh extension?
First define your extension by creating a protocol class, a session class, and an entry point class.
Declare the extension using the project configuration file, with the extension URI scheme being the group name and the extension URI path being the entry point name.
### Sample implementation of extension.
myexts/hello.py
from myrrh.core.exts.interfaces import IExtSession, uri_rd
from myrrh.core.exts.protocol import StdExtSession, MyrrhExtBase
from myrrh.core.exts.misc import URI
from myrrh.core.exts.errors import InvalidPath
class IEchoProtocol(IExtProtocol):
@uri_rd
@abc.abstractmethod
def hello(self): ...
class HelloSession(StdExtSession, IEchoProtocol):
def __init__(self, path):
super().__init__(IEchoProtocol)
self.path = path
def hello(self, myname):
return f"Hello {myname} from {self.path}"
class Hello(MyrrhExtBase):
def open(self, uri: str, *, req = None) -> HelloSession:
path = URI(uri).path.removeprefix(self._path)
return HelloSession(path)
def extend(self, path: str, _obj):
raise InvalidPath(path)
myexts/pyproject.toml
...
[myproject.exts]
/my/ext/path = "myext.hello:Hello"
...
myexts/main.py
from myrrh.core.exts.registry import Registry
Register().loads("myproject.exts")
with Registry().open("myproject.core.exts:/my/ext/path?=hello&myname=PyAnjel7") as f:
open_resp = f.read(1)
c = Registry().client("myproject.core.exts:/my/ext/path")
with c.open():
client_resp = c.hello('Pyanjel7')
assert open_resp == client_resp
Command line tool
usage: mexts [-h] {push,get,list} uri
positional arguments: {push,get,list} uri
options: -h, --help show this help message and exit
> mexts get "myrrh.core.exts:/registry?=loaded"
[['myrrh.core.exts:/registry']]
> mexts get "myrrh.core.exts:/registry?=__proto__"
[['findall', 'loaded']]
License
GNU General Public License v3.0 or later
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file myrrh_core_exts-0.1.0.tar.gz
.
File metadata
- Download URL: myrrh_core_exts-0.1.0.tar.gz
- Upload date:
- Size: 28.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb7dc4317cf495d2dc897f5c1bafe4b1390b8d4b95fd7422cde2e7f459f2f038 |
|
MD5 | 8262590b2fec8c940ade0ab010ba2b61 |
|
BLAKE2b-256 | 29256b42aef7426a10f4a18df7b902b1c9a4a909f8a65f9ce3dd1fefadcea6c0 |
File details
Details for the file myrrh_core_exts-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: myrrh_core_exts-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1ba8a6f1490ee928e66acd15b0f8bd36e01a54f3f40602107bd59efc0c0351e |
|
MD5 | af8c4541db6b76162be0961baffe2a6a |
|
BLAKE2b-256 | 30b6df35520f802614f6661fb29ce1599f860e99d9b3cc2bd6c202a0cf540d95 |