scruby-plugin 0.2.3__py3-none-any.whl
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.
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Copyright (c) 2026 Gennady Kostyunin
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Scruby-Plugin - Library for creating Scruby plugins."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
__all__ = ("ScrubyPlugin",)
|
|
8
|
+
|
|
9
|
+
import weakref
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ScrubyPlugin: # noqa: RUF067
|
|
14
|
+
"""Base class for creating Scruby plugins."""
|
|
15
|
+
|
|
16
|
+
def __init__(self, scruby: Any) -> None: # noqa: D107
|
|
17
|
+
self.scruby = weakref.ref(scruby)
|
scruby_plugin/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scruby-plugin
|
|
3
|
+
Version: 0.2.3
|
|
4
|
+
Summary: Library for creating Scruby plugins.
|
|
5
|
+
Keywords: scruby,plugin,database
|
|
6
|
+
Author: kebasyaty
|
|
7
|
+
Author-email: kebasyaty <kebasyaty@gmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
14
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
15
|
+
Classifier: Operating System :: POSIX
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.12, <4.0
|
|
27
|
+
Project-URL: Bug Tracker, https://github.com/kebasyaty/scruby-plugin/issues
|
|
28
|
+
Project-URL: Changelog, https://github.com/kebasyaty/scruby-plugin/blob/v0/CHANGELOG.md
|
|
29
|
+
Project-URL: Homepage, https://github.com/kebasyaty/scruby-plugin
|
|
30
|
+
Project-URL: Repository, https://github.com/kebasyaty/scruby-plugin
|
|
31
|
+
Project-URL: Source, https://github.com/kebasyaty/scruby-plugin
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# scruby-plugin
|
|
35
|
+
|
|
36
|
+
Library for creating Scruby plugins.
|
|
37
|
+
|
|
38
|
+
<br>
|
|
39
|
+
<br>
|
|
40
|
+
|
|
41
|
+
<p>
|
|
42
|
+
<a href="https://github.com/kebasyaty/scruby-plugin/actions/workflows/test.yml" alt="Build Status"><img src="https://github.com/kebasyaty/scruby-plugin/actions/workflows/test.yml/badge.svg" alt="Build Status"></a>
|
|
43
|
+
<a href="https://pypi.python.org/pypi/scruby-plugin/" alt="PyPI pyversions"><img src="https://img.shields.io/pypi/pyversions/scruby-plugin.svg" alt="PyPI pyversions"></a>
|
|
44
|
+
<a href="https://pypi.python.org/pypi/scruby-plugin/" alt="PyPI status"><img src="https://img.shields.io/pypi/status/scruby-plugin.svg" alt="PyPI status"></a>
|
|
45
|
+
<a href="https://pypi.python.org/pypi/scruby-plugin/" alt="PyPI version fury.io"><img src="https://badge.fury.io/py/scruby-plugin.svg" alt="PyPI version fury.io"></a>
|
|
46
|
+
<br>
|
|
47
|
+
<a href="https://pyrefly.org/" alt="Types: Pyrefly"><img src="https://img.shields.io/badge/types-Pyrefly-FFB74D.svg" alt="Types: Pyrefly"></a>
|
|
48
|
+
<a href="https://docs.astral.sh/ruff/" alt="Code style: Ruff"><img src="https://img.shields.io/badge/code%20style-Ruff-FDD835.svg" alt="Code style: Ruff"></a>
|
|
49
|
+
<a href="https://pypi.org/project/scruby-plugin"><img src="https://img.shields.io/pypi/format/scruby-plugin" alt="Format"></a>
|
|
50
|
+
<a href="https://pepy.tech/projects/scruby-plugin"><img src="https://static.pepy.tech/badge/scruby-plugin" alt="PyPI Downloads"></a>
|
|
51
|
+
<a href="https://github.com/kebasyaty/scruby-plugin/blob/main/LICENSE" alt="GitHub license"><img src="https://img.shields.io/github/license/kebasyaty/scruby-plugin" alt="GitHub license"></a>
|
|
52
|
+
</p>
|
|
53
|
+
|
|
54
|
+
<br>
|
|
55
|
+
|
|
56
|
+
## Requirements
|
|
57
|
+
|
|
58
|
+
[View the list of requirements](https://github.com/kebasyaty/scruby-plugin/blob/v0/REQUIREMENTS.md "Requirements").
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
```shell
|
|
63
|
+
uv add scruby-plugin
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from typing import Any
|
|
70
|
+
from scruby_plugin import ScrubyPlugin
|
|
71
|
+
|
|
72
|
+
class PluginName(ScrubyPlugin):
|
|
73
|
+
def __init__(self, scruby: Any) -> None:
|
|
74
|
+
ScrubyPlugin.__init__(self, scruby)
|
|
75
|
+
|
|
76
|
+
...your code...
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Example
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
import anyio
|
|
83
|
+
from typing import Any
|
|
84
|
+
from pydantic import Field
|
|
85
|
+
from scruby import Scruby, ScrubyModel, settings
|
|
86
|
+
from scruby_plugin import ScrubyPlugin
|
|
87
|
+
from pprint import pprint as pp
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
# Create plugin
|
|
91
|
+
class CollectionMeta(ScrubyPlugin):
|
|
92
|
+
def __init__(self, scruby: Any) -> None:
|
|
93
|
+
ScrubyPlugin.__init__(self, scruby)
|
|
94
|
+
|
|
95
|
+
async def get(self) -> Any:
|
|
96
|
+
scruby = self.scruby()
|
|
97
|
+
return await scruby.get_meta()
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
# Plugins connection.
|
|
101
|
+
settings.PLUGINS = [
|
|
102
|
+
CollectionMeta,
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class Car(ScrubyModel):
|
|
107
|
+
"""Car model."""
|
|
108
|
+
|
|
109
|
+
brand: str = Field(strict=True, frozen=True)
|
|
110
|
+
model: str = Field(strict=True, frozen=True)
|
|
111
|
+
year: int = Field(strict=True)
|
|
112
|
+
power_reserve: int = Field(strict=True)
|
|
113
|
+
# key is always at bottom
|
|
114
|
+
key: str = Field(
|
|
115
|
+
strict=True,
|
|
116
|
+
frozen=True,
|
|
117
|
+
default_factory=lambda data: f"{data['brand']}:{data['model']}",
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
async def main() -> None:
|
|
122
|
+
# Get collection `Car`.
|
|
123
|
+
car_coll = await Scruby.collection(Car)
|
|
124
|
+
# Get metadata of collection
|
|
125
|
+
meta = await car_coll.plugins.collectionMeta.get()
|
|
126
|
+
# Print to console
|
|
127
|
+
pp(meta)
|
|
128
|
+
#
|
|
129
|
+
# Full database deletion.
|
|
130
|
+
# Hint: The main purpose is tests.
|
|
131
|
+
Scruby.napalm()
|
|
132
|
+
|
|
133
|
+
if __name__ == "__main__":
|
|
134
|
+
anyio.run(main)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Changelog
|
|
138
|
+
|
|
139
|
+
[View the change history](https://github.com/kebasyaty/scruby-plugin/blob/v0/CHANGELOG.md "Changelog").
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
This project is licensed under the [MIT](https://github.com/kebasyaty/scruby-plugin/blob/main/LICENSE "MIT").
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
scruby_plugin/__init__.py,sha256=LQGjuPOGApeKRrISomnqXLPhDzqO5Qoi5TWAL0ND1nU,423
|
|
2
|
+
scruby_plugin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
scruby_plugin-0.2.3.dist-info/licenses/LICENSE,sha256=mvh5qv1YJGyuVCkRxonDDNOzxlwXszKvwxXfOeXKrqw,1074
|
|
4
|
+
scruby_plugin-0.2.3.dist-info/WHEEL,sha256=eycQt0QpYmJMLKpE3X9iDk8R04v2ZF0x82ogq-zP6bQ,79
|
|
5
|
+
scruby_plugin-0.2.3.dist-info/METADATA,sha256=ewqLWgI3rfT21iwP-u1xgB3dDAwU-qANxXr3NkfsCXA,5025
|
|
6
|
+
scruby_plugin-0.2.3.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gennady Kostyunin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|