haybale-core 0.0.2__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.
- haybale_core-0.0.2/.gitignore +205 -0
- haybale_core-0.0.2/PKG-INFO +94 -0
- haybale_core-0.0.2/README.md +83 -0
- haybale_core-0.0.2/haybale_core/__init__.py +77 -0
- haybale_core-0.0.2/haybale_core/adapters/__init__.py +14 -0
- haybale_core-0.0.2/haybale_core/adapters/basic_adapters.py +55 -0
- haybale_core-0.0.2/haybale_core/adapters/compound_adapters.py +61 -0
- haybale_core-0.0.2/haybale_core/nodes/__init__.py +22 -0
- haybale_core-0.0.2/haybale_core/nodes/emits/tick_emit.py +138 -0
- haybale_core-0.0.2/haybale_core/nodes/error_node.py +24 -0
- haybale_core-0.0.2/haybale_core/nodes/events/begin_play.py +39 -0
- haybale_core-0.0.2/haybale_core/nodes/events/shutdown.py +91 -0
- haybale_core-0.0.2/haybale_core/nodes/events/tick_event.py +49 -0
- haybale_core-0.0.2/haybale_core/nodes/for_loop.py +153 -0
- haybale_core-0.0.2/haybale_core/nodes/print_terminal.py +26 -0
- haybale_core-0.0.2/haybale_core/nodes/print_ui_log.py +27 -0
- haybale_core-0.0.2/haybale_core/nodes/switch.py +114 -0
- haybale_core-0.0.2/haybale_core/panels/__init__.py +0 -0
- haybale_core-0.0.2/haybale_core/py.typed +0 -0
- haybale_core-0.0.2/haybale_core/themes/__init__.py +1 -0
- haybale_core-0.0.2/haybale_core/types/__init__.py +36 -0
- haybale_core-0.0.2/haybale_core/types/array_type.py +183 -0
- haybale_core-0.0.2/haybale_core/types/pooled_type.py +256 -0
- haybale_core-0.0.2/haybale_core/types/specs.py +250 -0
- haybale_core-0.0.2/haybale_core/widgets/__init__.py +18 -0
- haybale_core-0.0.2/haybale_core/widgets/basic_widgets.py +211 -0
- haybale_core-0.0.2/pyproject.toml +33 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
|
|
110
|
+
# pdm
|
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
112
|
+
#pdm.lock
|
|
113
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
114
|
+
# in version control.
|
|
115
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
116
|
+
.pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
**/.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
.idea/
|
|
169
|
+
|
|
170
|
+
# Abstra
|
|
171
|
+
# Abstra is an AI-powered process automation framework.
|
|
172
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
173
|
+
# Learn more at https://abstra.io/docs
|
|
174
|
+
.abstra/
|
|
175
|
+
|
|
176
|
+
# Visual Studio Code
|
|
177
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
178
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
179
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
180
|
+
# you could uncomment the following to ignore the enitre vscode folder
|
|
181
|
+
.vscode/
|
|
182
|
+
|
|
183
|
+
# Ruff stuff:
|
|
184
|
+
.ruff_cache/
|
|
185
|
+
|
|
186
|
+
# PyPI configuration file
|
|
187
|
+
.pypirc
|
|
188
|
+
|
|
189
|
+
# Cursor
|
|
190
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
191
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
192
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
193
|
+
.cursorignore
|
|
194
|
+
.cursorindexingignore
|
|
195
|
+
|
|
196
|
+
.DS_Store
|
|
197
|
+
saves/*.*
|
|
198
|
+
|
|
199
|
+
# Dev-mode graphs (local testing only, not part of the repo)
|
|
200
|
+
graphs/*.json
|
|
201
|
+
# MkDocs build output
|
|
202
|
+
site/
|
|
203
|
+
|
|
204
|
+
# Local git worktrees (claude-code workflow)
|
|
205
|
+
.worktrees/
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: haybale-core
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: Core library for Haywire node system with core types, nodes, widgets, and renderers
|
|
5
|
+
Author: Haywire Team
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: core,haywire,node-editor,visual-programming
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Requires-Dist: haywire-core~=0.0.2
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# Haywire Core Library
|
|
13
|
+
|
|
14
|
+
This is a core library providing essential types, nodes, widgets, and renderers for the Haywire library system.
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- **Types**: Core data types with serialization support
|
|
19
|
+
- **Nodes**: Nodes for data processing and display
|
|
20
|
+
- **Widgets**: UI widgets for node configuration
|
|
21
|
+
- **Renderers**: Node rendering customization
|
|
22
|
+
- **Adapters**: Integration with external systems
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
### Development (Editable Install)
|
|
27
|
+
|
|
28
|
+
For development with hot-reload support:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
cd libraries/haybale-core
|
|
32
|
+
uv pip install -e .
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Production
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
uv pip install haybale-core
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
Once installed, the library is automatically discovered by Haywire through entry points.
|
|
44
|
+
|
|
45
|
+
The library provides:
|
|
46
|
+
- Display nodes for visualization
|
|
47
|
+
- Dynamic nodes for runtime node creation
|
|
48
|
+
- Core data types
|
|
49
|
+
- Core UI widgets and renderers
|
|
50
|
+
|
|
51
|
+
## Structure
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
📁 haybale-core/ # Git repo name / unique pip package name
|
|
55
|
+
├── pyproject.toml
|
|
56
|
+
│ [project]
|
|
57
|
+
│ name = "haybale-core" # pip install haybale-core
|
|
58
|
+
│
|
|
59
|
+
│ [project.entry-points."haywire.libraries"]
|
|
60
|
+
│ core = "haybale_core:Library" # ID matches module
|
|
61
|
+
│
|
|
62
|
+
└── 📁 haybale_core/ # import haybale_core
|
|
63
|
+
├── __init__.py
|
|
64
|
+
│ @library(
|
|
65
|
+
│ id='CORE', # Matches entry point
|
|
66
|
+
│ label='Core Library',
|
|
67
|
+
│ )
|
|
68
|
+
│ class Library(BaseLibrary): ...
|
|
69
|
+
├── nodes/ # Core nodes
|
|
70
|
+
├── types/ # Core data types (if any)
|
|
71
|
+
├── widgets/ # Core UI widgets
|
|
72
|
+
├── renderers/ # Core node renderers
|
|
73
|
+
└── adapters/ # Core system adapters
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Development
|
|
77
|
+
|
|
78
|
+
After making changes to the library code:
|
|
79
|
+
|
|
80
|
+
1. **With editable install**: Changes are immediately reflected (after hot-reload)
|
|
81
|
+
2. **Without editable install**: Reinstall the package
|
|
82
|
+
|
|
83
|
+
## Entry Point
|
|
84
|
+
|
|
85
|
+
This library is discoverable via the `haywire.libraries` entry point:
|
|
86
|
+
|
|
87
|
+
```toml
|
|
88
|
+
[project.entry-points."haywire.libraries"]
|
|
89
|
+
core = "haybale_core:Library"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Dependencies
|
|
93
|
+
|
|
94
|
+
- None
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Haywire Core Library
|
|
2
|
+
|
|
3
|
+
This is a core library providing essential types, nodes, widgets, and renderers for the Haywire library system.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Types**: Core data types with serialization support
|
|
8
|
+
- **Nodes**: Nodes for data processing and display
|
|
9
|
+
- **Widgets**: UI widgets for node configuration
|
|
10
|
+
- **Renderers**: Node rendering customization
|
|
11
|
+
- **Adapters**: Integration with external systems
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
### Development (Editable Install)
|
|
16
|
+
|
|
17
|
+
For development with hot-reload support:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
cd libraries/haybale-core
|
|
21
|
+
uv pip install -e .
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Production
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
uv pip install haybale-core
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
Once installed, the library is automatically discovered by Haywire through entry points.
|
|
33
|
+
|
|
34
|
+
The library provides:
|
|
35
|
+
- Display nodes for visualization
|
|
36
|
+
- Dynamic nodes for runtime node creation
|
|
37
|
+
- Core data types
|
|
38
|
+
- Core UI widgets and renderers
|
|
39
|
+
|
|
40
|
+
## Structure
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
📁 haybale-core/ # Git repo name / unique pip package name
|
|
44
|
+
├── pyproject.toml
|
|
45
|
+
│ [project]
|
|
46
|
+
│ name = "haybale-core" # pip install haybale-core
|
|
47
|
+
│
|
|
48
|
+
│ [project.entry-points."haywire.libraries"]
|
|
49
|
+
│ core = "haybale_core:Library" # ID matches module
|
|
50
|
+
│
|
|
51
|
+
└── 📁 haybale_core/ # import haybale_core
|
|
52
|
+
├── __init__.py
|
|
53
|
+
│ @library(
|
|
54
|
+
│ id='CORE', # Matches entry point
|
|
55
|
+
│ label='Core Library',
|
|
56
|
+
│ )
|
|
57
|
+
│ class Library(BaseLibrary): ...
|
|
58
|
+
├── nodes/ # Core nodes
|
|
59
|
+
├── types/ # Core data types (if any)
|
|
60
|
+
├── widgets/ # Core UI widgets
|
|
61
|
+
├── renderers/ # Core node renderers
|
|
62
|
+
└── adapters/ # Core system adapters
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Development
|
|
66
|
+
|
|
67
|
+
After making changes to the library code:
|
|
68
|
+
|
|
69
|
+
1. **With editable install**: Changes are immediately reflected (after hot-reload)
|
|
70
|
+
2. **Without editable install**: Reinstall the package
|
|
71
|
+
|
|
72
|
+
## Entry Point
|
|
73
|
+
|
|
74
|
+
This library is discoverable via the `haywire.libraries` entry point:
|
|
75
|
+
|
|
76
|
+
```toml
|
|
77
|
+
[project.entry-points."haywire.libraries"]
|
|
78
|
+
core = "haybale_core:Library"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Dependencies
|
|
82
|
+
|
|
83
|
+
- None
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Haywire Core Library
|
|
3
|
+
|
|
4
|
+
Contains fundamental nodes, widgets, adapters, and data definitions
|
|
5
|
+
that form the foundation of the Haywire system.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from importlib.metadata import version as _pkg_version
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from haywire.core.library.base import BaseLibrary
|
|
12
|
+
from haywire.core.library.decorator import library
|
|
13
|
+
from haywire.core.settings.registry import SettingsRegistry
|
|
14
|
+
from haywire.core.adapter.registry import AdapterRegistry
|
|
15
|
+
from haywire.core.node.registry import NodeRegistry
|
|
16
|
+
from haywire.core.types.registry import TypeRegistry
|
|
17
|
+
|
|
18
|
+
from haywire.ui.panel.registry import PanelRegistry
|
|
19
|
+
from haywire.ui.editor.registry import EditorTypeRegistry
|
|
20
|
+
from haywire.ui.themes.registry import ThemeRegistry
|
|
21
|
+
from haywire.ui.widget.registry import WidgetRegistry
|
|
22
|
+
from haywire.ui.skin.registry import SkinRegistry
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@library(
|
|
26
|
+
label="Haywire Core",
|
|
27
|
+
id="core",
|
|
28
|
+
version=_pkg_version("haybale-core"),
|
|
29
|
+
description="Core Haywire library with fundamental components",
|
|
30
|
+
url="https://github.com/maybites/haywire",
|
|
31
|
+
help_url="https://github.com/maybites/haywire",
|
|
32
|
+
author="maybites",
|
|
33
|
+
author_url="https://maybites.ch",
|
|
34
|
+
dependencies=[],
|
|
35
|
+
tags=["core", "types", "widgets", "skins"],
|
|
36
|
+
file_watcher=False,
|
|
37
|
+
)
|
|
38
|
+
class Library(BaseLibrary):
|
|
39
|
+
"""Core Haywire library implementation"""
|
|
40
|
+
|
|
41
|
+
def register_components(self):
|
|
42
|
+
"""Register all core components with the global registries"""
|
|
43
|
+
|
|
44
|
+
"""Register nodes and custom types"""
|
|
45
|
+
base_path = Path(__file__).parent
|
|
46
|
+
|
|
47
|
+
# Register settings
|
|
48
|
+
self.add_folder_to_registry(folder_path=str(base_path / "settings"), registry_cls=SettingsRegistry)
|
|
49
|
+
|
|
50
|
+
# Register themes (workbench and node themes)
|
|
51
|
+
self.add_folder_to_registry(folder_path=str(base_path / "themes"), registry_cls=ThemeRegistry)
|
|
52
|
+
|
|
53
|
+
# Register types (both variants and custom types)
|
|
54
|
+
self.add_folder_to_registry(folder_path=str(base_path / "types"), registry_cls=TypeRegistry)
|
|
55
|
+
|
|
56
|
+
# Register adapters (now includes data types)
|
|
57
|
+
self.add_folder_to_registry(folder_path=str(base_path / "adapters"), registry_cls=AdapterRegistry)
|
|
58
|
+
|
|
59
|
+
# Register widgets
|
|
60
|
+
self.add_folder_to_registry(folder_path=str(base_path / "widgets"), registry_cls=WidgetRegistry)
|
|
61
|
+
|
|
62
|
+
# Register skins (node skins)
|
|
63
|
+
self.add_folder_to_registry(folder_path=str(base_path / "skins"), registry_cls=SkinRegistry)
|
|
64
|
+
|
|
65
|
+
# Register nodes
|
|
66
|
+
self.add_folder_to_registry(folder_path=str(base_path / "nodes"), registry_cls=NodeRegistry)
|
|
67
|
+
|
|
68
|
+
# Register nodes
|
|
69
|
+
self.add_folder_to_registry(folder_path=str(base_path / "panels"), registry_cls=PanelRegistry)
|
|
70
|
+
|
|
71
|
+
# Register nodes
|
|
72
|
+
self.add_folder_to_registry(folder_path=str(base_path / "editors"), registry_cls=EditorTypeRegistry)
|
|
73
|
+
|
|
74
|
+
def validate(self) -> bool:
|
|
75
|
+
"""Validate that the core library is properly structured"""
|
|
76
|
+
# Core library is always valid since it's part of the system
|
|
77
|
+
return True
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from .basic_adapters import IntToFloatAdapter
|
|
2
|
+
from .basic_adapters import FloatToIntAdapter
|
|
3
|
+
from .basic_adapters import FloatToStringAdapter
|
|
4
|
+
from .basic_adapters import BoolToIntAdapter
|
|
5
|
+
from .compound_adapters import ArrayArrayAdapter
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"ArrayArrayAdapter",
|
|
10
|
+
"BoolToIntAdapter",
|
|
11
|
+
"FloatToIntAdapter",
|
|
12
|
+
"FloatToStringAdapter",
|
|
13
|
+
"IntToFloatAdapter",
|
|
14
|
+
]
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Basic type conversion adapters
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import random
|
|
6
|
+
from typing_extensions import override
|
|
7
|
+
|
|
8
|
+
from haywire.core.adapter.base import BaseAdapter
|
|
9
|
+
from haywire.core.adapter.base import adapter
|
|
10
|
+
|
|
11
|
+
from ..types.specs import BOOL, FLOAT, INT, STRING
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@adapter(description="Convert integer to float", converts_from=INT, converts_to=FLOAT)
|
|
15
|
+
class IntToFloatAdapter(BaseAdapter):
|
|
16
|
+
@override
|
|
17
|
+
def convert(self, value: int) -> float:
|
|
18
|
+
return float(value)
|
|
19
|
+
|
|
20
|
+
def get_test_value(self) -> int:
|
|
21
|
+
return int(random.randrange(0, 100))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@adapter(description="Convert float to integer", converts_from=FLOAT, converts_to=INT)
|
|
25
|
+
class FloatToIntAdapter(BaseAdapter):
|
|
26
|
+
@override
|
|
27
|
+
def convert(self, value: float) -> int:
|
|
28
|
+
return int(value)
|
|
29
|
+
|
|
30
|
+
def get_test_value(self) -> float:
|
|
31
|
+
return float(random.randrange(0, 100) * 1.0)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@adapter(description="Convert float to integer", converts_from=FLOAT, converts_to=STRING)
|
|
35
|
+
class FloatToStringAdapter(BaseAdapter):
|
|
36
|
+
"""Convert integer to float"""
|
|
37
|
+
|
|
38
|
+
@override
|
|
39
|
+
def convert(self, value: float) -> str:
|
|
40
|
+
return str(value)
|
|
41
|
+
|
|
42
|
+
def get_test_value(self) -> float:
|
|
43
|
+
return float(random.randrange(0, 100))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@adapter(description="Convert bool to integer", converts_from=BOOL, converts_to=INT)
|
|
47
|
+
class BoolToIntAdapter(BaseAdapter):
|
|
48
|
+
"""Convert bool to integer"""
|
|
49
|
+
|
|
50
|
+
@override
|
|
51
|
+
def convert(self, value: bool) -> int:
|
|
52
|
+
return int(value)
|
|
53
|
+
|
|
54
|
+
def get_test_value(self) -> bool:
|
|
55
|
+
return random.choice([True, False])
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from typing import Any, List
|
|
2
|
+
from typing_extensions import override
|
|
3
|
+
|
|
4
|
+
from haywire.core.adapter.base import adapter, BaseAdapter
|
|
5
|
+
|
|
6
|
+
from ..types.array_type import ArrayType
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@adapter(
|
|
10
|
+
label="Array to Array",
|
|
11
|
+
description="Transform array elements (ArrayType[X] → ArrayType[Y])",
|
|
12
|
+
converts_from=ArrayType,
|
|
13
|
+
converts_to=ArrayType,
|
|
14
|
+
priority=0,
|
|
15
|
+
)
|
|
16
|
+
class ArrayArrayAdapter(BaseAdapter):
|
|
17
|
+
"""
|
|
18
|
+
Transforms ArrayType[X] → ArrayType[Y].
|
|
19
|
+
|
|
20
|
+
Uses internal adapter chain for element transformation.
|
|
21
|
+
Always skips None values to prevent chain failures.
|
|
22
|
+
|
|
23
|
+
Examples:
|
|
24
|
+
# ArrayType[FLOAT] → ArrayType[FLOAT] (no element transformation)
|
|
25
|
+
adapter = ArrayArrayAdapter()
|
|
26
|
+
result = adapter.convert([1.0, 2.0, 3.0])
|
|
27
|
+
# → [1.0, 2.0, 3.0]
|
|
28
|
+
|
|
29
|
+
# ArrayType[FLOAT] → ArrayType[STRING] (with element transformation)
|
|
30
|
+
float_to_str = FloatToStringAdapter()
|
|
31
|
+
adapter = ArrayArrayAdapter(element_adapter=float_to_str)
|
|
32
|
+
result = adapter.convert([1.5, None, 2.7])
|
|
33
|
+
# → ["1.50", "2.70"] (None skipped)
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
@override
|
|
37
|
+
def convert(self, values: List[Any]) -> List[Any]:
|
|
38
|
+
"""
|
|
39
|
+
Transform each element or pass through.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
values: List of source elements
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
List of transformed elements (None values skipped)
|
|
46
|
+
"""
|
|
47
|
+
return [
|
|
48
|
+
self._chain.execute(v)
|
|
49
|
+
for v in values
|
|
50
|
+
if v is not None # Always skip None
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
# Override to execute conversion since we treat the inner chain as element adapter
|
|
54
|
+
@override
|
|
55
|
+
def execute(self, value):
|
|
56
|
+
return self.convert(value)
|
|
57
|
+
|
|
58
|
+
@override
|
|
59
|
+
def get_test_value(self) -> Any:
|
|
60
|
+
# Generate list of random values from the element adapter chain
|
|
61
|
+
return [self._chain.get_test_value() for _ in range(5)]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from .error_node import ErrorNode
|
|
2
|
+
from .for_loop import ForLoopNode
|
|
3
|
+
from .print_terminal import PrintTerminalMessageNode
|
|
4
|
+
from .print_ui_log import PrintLogNode
|
|
5
|
+
from .switch import ControlSwitch
|
|
6
|
+
from .emits.tick_emit import TickEmitNode
|
|
7
|
+
from .events.begin_play import BeginPlayNode
|
|
8
|
+
from .events.shutdown import ShutdownNode
|
|
9
|
+
from .events.tick_event import TickEventNode
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"BeginPlayNode",
|
|
14
|
+
"ControlSwitch",
|
|
15
|
+
"ErrorNode",
|
|
16
|
+
"ForLoopNode",
|
|
17
|
+
"PrintLogNode",
|
|
18
|
+
"PrintTerminalMessageNode",
|
|
19
|
+
"ShutdownNode",
|
|
20
|
+
"TickEmitNode",
|
|
21
|
+
"TickEventNode",
|
|
22
|
+
]
|