swarmauri_state_clipboard 0.6.0.dev154__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.
- swarmauri_state_clipboard-0.6.0.dev154/PKG-INFO +20 -0
- swarmauri_state_clipboard-0.6.0.dev154/README.md +1 -0
- swarmauri_state_clipboard-0.6.0.dev154/pyproject.toml +57 -0
- swarmauri_state_clipboard-0.6.0.dev154/swarmauri_state_clipboard/ClipboardState.py +72 -0
- swarmauri_state_clipboard-0.6.0.dev154/swarmauri_state_clipboard/__init__.py +12 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: swarmauri_state_clipboard
|
|
3
|
+
Version: 0.6.0.dev154
|
|
4
|
+
Summary: Swarmauri Community Clipboard State
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Author: Jacob Stewart
|
|
7
|
+
Author-email: jacob@swarmauri.com
|
|
8
|
+
Requires-Python: >=3.10,<3.13
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Requires-Dist: pyperclip (>=1.8.3,<2.0.0)
|
|
15
|
+
Requires-Dist: swarmauri_base (>=0.6.0.dev154,<0.7.0)
|
|
16
|
+
Requires-Dist: swarmauri_core (>=0.6.0.dev154,<0.7.0)
|
|
17
|
+
Project-URL: Repository, http://github.com/swarmauri/swarmauri-sdk
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# Swarmauri Example Community Package
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Swarmauri Example Community Package
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "swarmauri_state_clipboard"
|
|
3
|
+
version = "0.6.0.dev154"
|
|
4
|
+
description = "Swarmauri Community Clipboard State"
|
|
5
|
+
authors = ["Jacob Stewart <jacob@swarmauri.com>"]
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
repository = "http://github.com/swarmauri/swarmauri-sdk"
|
|
9
|
+
classifiers = [
|
|
10
|
+
"License :: OSI Approved :: Apache Software License",
|
|
11
|
+
"Programming Language :: Python :: 3.10",
|
|
12
|
+
"Programming Language :: Python :: 3.11",
|
|
13
|
+
"Programming Language :: Python :: 3.12"
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[tool.poetry.dependencies]
|
|
17
|
+
python = ">=3.10,<3.13"
|
|
18
|
+
|
|
19
|
+
# Swarmauri
|
|
20
|
+
swarmauri_core = {version = "^0.6.0.dev154"}
|
|
21
|
+
swarmauri_base = {version = "^0.6.0.dev154"}
|
|
22
|
+
|
|
23
|
+
# dependencies
|
|
24
|
+
pyperclip = "^1.8.3"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
[tool.poetry.group.dev.dependencies]
|
|
28
|
+
flake8 = "^7.0"
|
|
29
|
+
pytest = "^8.0"
|
|
30
|
+
pytest-asyncio = ">=0.24.0"
|
|
31
|
+
pytest-xdist = "^3.6.1"
|
|
32
|
+
pytest-json-report = "^1.5.0"
|
|
33
|
+
python-dotenv = "*"
|
|
34
|
+
requests = "^2.32.3"
|
|
35
|
+
|
|
36
|
+
[build-system]
|
|
37
|
+
requires = ["poetry-core>=1.0.0"]
|
|
38
|
+
build-backend = "poetry.core.masonry.api"
|
|
39
|
+
|
|
40
|
+
[tool.pytest.ini_options]
|
|
41
|
+
norecursedirs = ["combined", "scripts"]
|
|
42
|
+
|
|
43
|
+
markers = [
|
|
44
|
+
"test: standard test",
|
|
45
|
+
"unit: Unit tests",
|
|
46
|
+
"integration: Integration tests",
|
|
47
|
+
"acceptance: Acceptance tests",
|
|
48
|
+
"experimental: Experimental tests"
|
|
49
|
+
]
|
|
50
|
+
log_cli = true
|
|
51
|
+
log_cli_level = "INFO"
|
|
52
|
+
log_cli_format = "%(asctime)s [%(levelname)s] %(message)s"
|
|
53
|
+
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
|
|
54
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
55
|
+
|
|
56
|
+
[tool.poetry.plugins."swarmauri.states"]
|
|
57
|
+
ClipboardState = "swarmauri_state_clipboard.ClipboardState:ClipboardState"
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from swarmauri_core.ComponentBase import ComponentBase
|
|
2
|
+
import pyperclip
|
|
3
|
+
from typing import Dict, Any
|
|
4
|
+
from swarmauri_base.state.StateBase import StateBase
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@ComponentBase.register_type(StateBase, "ClipboardState")
|
|
8
|
+
class ClipboardState(StateBase):
|
|
9
|
+
"""
|
|
10
|
+
A concrete implementation of StateBase that uses the system clipboard to store and retrieve state data.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def read(self) -> Dict[str, Any]:
|
|
14
|
+
"""
|
|
15
|
+
Reads the current state from the clipboard as a dictionary.
|
|
16
|
+
"""
|
|
17
|
+
try:
|
|
18
|
+
clipboard_content = pyperclip.paste()
|
|
19
|
+
# Ensure the clipboard contains valid data (e.g., a JSON string that can be parsed)
|
|
20
|
+
if clipboard_content:
|
|
21
|
+
return eval(
|
|
22
|
+
clipboard_content
|
|
23
|
+
) # Replace eval with JSON for safer parsing
|
|
24
|
+
return {}
|
|
25
|
+
except Exception as e:
|
|
26
|
+
raise ValueError(f"Failed to read state from clipboard: {e}")
|
|
27
|
+
|
|
28
|
+
def write(self, data: Dict[str, Any]) -> None:
|
|
29
|
+
"""
|
|
30
|
+
Replaces the current state with the given data by copying it to the clipboard.
|
|
31
|
+
"""
|
|
32
|
+
try:
|
|
33
|
+
pyperclip.copy(
|
|
34
|
+
str(data)
|
|
35
|
+
) # Convert dictionary to string for clipboard storage
|
|
36
|
+
except Exception as e:
|
|
37
|
+
raise ValueError(f"Failed to write state to clipboard: {e}")
|
|
38
|
+
|
|
39
|
+
def update(self, data: Dict[str, Any]) -> None:
|
|
40
|
+
"""
|
|
41
|
+
Updates the current state with the given data by merging with clipboard content.
|
|
42
|
+
"""
|
|
43
|
+
try:
|
|
44
|
+
current_state = self.read()
|
|
45
|
+
current_state.update(data)
|
|
46
|
+
self.write(current_state)
|
|
47
|
+
except Exception as e:
|
|
48
|
+
raise ValueError(f"Failed to update state on clipboard: {e}")
|
|
49
|
+
|
|
50
|
+
def reset(self) -> None:
|
|
51
|
+
"""
|
|
52
|
+
Resets the clipboard state to an empty dictionary.
|
|
53
|
+
"""
|
|
54
|
+
try:
|
|
55
|
+
self.write({})
|
|
56
|
+
except Exception as e:
|
|
57
|
+
raise ValueError(f"Failed to reset clipboard state: {e}")
|
|
58
|
+
|
|
59
|
+
def deep_copy(self) -> "ClipboardState":
|
|
60
|
+
"""
|
|
61
|
+
Creates a deep copy of the current state. In this context, simply returns a new
|
|
62
|
+
ClipboardState with the same clipboard data.
|
|
63
|
+
"""
|
|
64
|
+
try:
|
|
65
|
+
current_state = self.read()
|
|
66
|
+
new_instance = ClipboardState()
|
|
67
|
+
new_instance.write(current_state)
|
|
68
|
+
return new_instance
|
|
69
|
+
except Exception as e:
|
|
70
|
+
raise ValueError(
|
|
71
|
+
f"Failed to create a deep copy of the clipboard state: {e}"
|
|
72
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from .ClipboardState import ClipboardState
|
|
2
|
+
|
|
3
|
+
__version__ = "0.6.0.dev26"
|
|
4
|
+
__long_desc__ = """
|
|
5
|
+
|
|
6
|
+
# Swarmauri Clipboard State Plugin
|
|
7
|
+
|
|
8
|
+
Visit us at: https://swarmauri.com
|
|
9
|
+
Follow us at: https://github.com/swarmauri
|
|
10
|
+
Star us at: https://github.com/swarmauri/swarmauri-sdk
|
|
11
|
+
|
|
12
|
+
"""
|