runtimepy 5.11.1__py3-none-any.whl → 5.11.2__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.
runtimepy/__init__.py CHANGED
@@ -1,7 +1,7 @@
1
1
  # =====================================
2
2
  # generator=datazen
3
3
  # version=3.1.4
4
- # hash=da21068ff2c7240dc103642dedb80cf5
4
+ # hash=c5b165c61995fe302ea31f7500b6359f
5
5
  # =====================================
6
6
 
7
7
  """
@@ -10,7 +10,7 @@ Useful defaults and other package metadata.
10
10
 
11
11
  DESCRIPTION = "A framework for implementing Python services."
12
12
  PKG_NAME = "runtimepy"
13
- VERSION = "5.11.1"
13
+ VERSION = "5.11.2"
14
14
 
15
15
  # runtimepy-specific content.
16
16
  METRICS_NAME = "metrics"
@@ -145,6 +145,7 @@ class ProtocolBase(PrimitiveArray):
145
145
  fields=_copy(self._fields),
146
146
  build=self._build,
147
147
  byte_order=self.byte_order,
148
+ identifier=self.id,
148
149
  serializables={
149
150
  key: [val[0].copy_without_chain()]
150
151
  for key, val in self.serializables.items()
@@ -25,6 +25,7 @@ from runtimepy.primitives.field.manager import (
25
25
  VALUES_KEY,
26
26
  BitFieldsManager,
27
27
  )
28
+ from runtimepy.primitives.serializable import SerializableMap
28
29
 
29
30
  BUILD_KEY = "build"
30
31
  META_KEY = "meta"
@@ -96,7 +97,11 @@ class JsonProtocol(ProtocolBase):
96
97
  return data
97
98
 
98
99
  @classmethod
99
- def import_json(cls: type[T], data: dict[str, _JsonObject]) -> T:
100
+ def import_json(
101
+ cls: type[T],
102
+ data: dict[str, _JsonObject],
103
+ serializables: SerializableMap = None,
104
+ ) -> T:
100
105
  """Create a bit-fields manager from JSON data."""
101
106
 
102
107
  # Only set values once (at the end).
@@ -126,6 +131,7 @@ class JsonProtocol(ProtocolBase):
126
131
  identifier=_cast(int, data[META_KEY]["id"]),
127
132
  byte_order=_cast(str, data[META_KEY]["byte_order"]),
128
133
  alias=data[META_KEY]["alias"], # type: ignore
134
+ serializables=serializables,
129
135
  )
130
136
 
131
137
  # Set values.
@@ -3,7 +3,7 @@ A basic type-system implementation.
3
3
  """
4
4
 
5
5
  # built-in
6
- from typing import Iterable, Optional
6
+ from typing import Iterable, Optional, Union
7
7
 
8
8
  # third-party
9
9
  from vcorelib.logging import LoggerMixin
@@ -18,8 +18,10 @@ from runtimepy.enum.registry import (
18
18
  EnumRegistry,
19
19
  RuntimeIntEnum,
20
20
  )
21
- from runtimepy.primitives.byte_order import ByteOrder
21
+ from runtimepy.primitives.byte_order import DEFAULT_BYTE_ORDER, ByteOrder
22
22
  from runtimepy.primitives.types import AnyPrimitiveType, PrimitiveTypes
23
+ from runtimepy.registry.name import RegistryKey
24
+ from runtimepy.util import Identifier
23
25
 
24
26
 
25
27
  def resolve_name(matches: Iterable[str]) -> str:
@@ -50,6 +52,8 @@ class TypeSystem(LoggerMixin):
50
52
 
51
53
  self.primitives: dict[str, AnyPrimitiveType] = {}
52
54
  self.custom: dict[str, Protocol] = {}
55
+ self.custom_ids = Identifier(scale=1)
56
+
53
57
  self._enums = EnumRegistry()
54
58
 
55
59
  global_namespace = Namespace(delim=CPP_DELIM)
@@ -98,11 +102,21 @@ class TypeSystem(LoggerMixin):
98
102
  assert enum is not None
99
103
  self._register_primitive(name, enum.primitive)
100
104
 
101
- def register(self, name: str, *namespace: str) -> Protocol:
105
+ def register(
106
+ self,
107
+ name: str,
108
+ *namespace: str,
109
+ byte_order: Union[ByteOrder, RegistryKey] = DEFAULT_BYTE_ORDER,
110
+ ) -> Protocol:
102
111
  """Register a custom type."""
103
112
 
104
113
  resolved = self._name(name, *namespace, check_available=True)
105
- new_type = Protocol(self._enums, alias=resolved)
114
+ new_type = Protocol(
115
+ self._enums,
116
+ alias=resolved,
117
+ identifier=self.custom_ids(),
118
+ byte_order=byte_order,
119
+ )
106
120
  self.custom[resolved] = new_type
107
121
  return new_type
108
122
 
@@ -63,6 +63,11 @@ class RuntimeIntEnum(_IntEnum):
63
63
 
64
64
  return data
65
65
 
66
+ @classmethod
67
+ def id(cls) -> _Optional[int]:
68
+ """Override in sub-class to coerce enum id."""
69
+ return None
70
+
66
71
  @classmethod
67
72
  def primitive(cls) -> str:
68
73
  """The underlying primitive type for this runtime enumeration."""
@@ -89,6 +94,20 @@ class RuntimeIntEnum(_IntEnum):
89
94
 
90
95
  data = _RuntimeEnum.data_from_enum(cls)
91
96
  data["primitive"] = cls.primitive()
97
+
98
+ ident = cls.id()
99
+ if ident is not None:
100
+ data["id"] = ident
101
+
92
102
  result = registry.register_dict(name, data)
93
103
  assert result is not None
94
104
  return result
105
+
106
+
107
+ def enum_registry(*kinds: type[RuntimeIntEnum]) -> EnumRegistry:
108
+ """Create an enum registry with the provided custom types registered."""
109
+
110
+ result = EnumRegistry()
111
+ for kind in kinds:
112
+ kind.register_enum(result)
113
+ return result
runtimepy/util.py CHANGED
@@ -34,10 +34,10 @@ def normalize_root(*src_parts: Union[str, Path]) -> Path:
34
34
  class Identifier:
35
35
  """A simple message indentifier interface."""
36
36
 
37
- def __init__(self) -> None:
37
+ def __init__(self, start: int = 1, scale: int = 2) -> None:
38
38
  """Initialize this instance."""
39
- self.curr_id: int = 1
40
- self.scale = 2
39
+ self.curr_id = start
40
+ self.scale = scale
41
41
 
42
42
  def __call__(self) -> int:
43
43
  """Get the next identifier."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: runtimepy
3
- Version: 5.11.1
3
+ Version: 5.11.2
4
4
  Summary: A framework for implementing Python services.
5
5
  Home-page: https://github.com/vkottler/runtimepy
6
6
  Author: Vaughn Kottler
@@ -18,10 +18,10 @@ Requires-Python: >=3.12
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
20
  Requires-Dist: psutil
21
- Requires-Dist: vcorelib>=3.5.1
21
+ Requires-Dist: websockets
22
22
  Requires-Dist: aiofiles
23
+ Requires-Dist: vcorelib>=3.5.1
23
24
  Requires-Dist: svgen>=0.7.4
24
- Requires-Dist: websockets
25
25
  Provides-Extra: test
26
26
  Requires-Dist: pylint; extra == "test"
27
27
  Requires-Dist: flake8; extra == "test"
@@ -50,11 +50,11 @@ Dynamic: requires-python
50
50
  =====================================
51
51
  generator=datazen
52
52
  version=3.1.4
53
- hash=4ef876633bf905b103835e81db45e721
53
+ hash=8a7622d7187fa17bfcc479f8f6f78d1a
54
54
  =====================================
55
55
  -->
56
56
 
57
- # runtimepy ([5.11.1](https://pypi.org/project/runtimepy/))
57
+ # runtimepy ([5.11.2](https://pypi.org/project/runtimepy/))
58
58
 
59
59
  [![python](https://img.shields.io/pypi/pyversions/runtimepy.svg)](https://pypi.org/project/runtimepy/)
60
60
  ![Build Status](https://github.com/vkottler/runtimepy/workflows/Python%20Package/badge.svg)
@@ -1,4 +1,4 @@
1
- runtimepy/__init__.py,sha256=jnVk66eyyfxqRlrnXybadQhrpwK0h8K50mULrq-N3xg,391
1
+ runtimepy/__init__.py,sha256=ClGjUTeqSc-7--8TPBkQrpNpwnkj6vXDfX4AMafRXRk,391
2
2
  runtimepy/__main__.py,sha256=OPAed6hggoQdw-6QAR62mqLC-rCkdDhOq0wyeS2vDRI,332
3
3
  runtimepy/app.py,sha256=sTvatbsGZ2Hdel36Si_WUbNMtg9CzsJyExr5xjIcxDE,970
4
4
  runtimepy/dev_requirements.txt,sha256=j0dh11ztJAzfaUL0iFheGjaZj9ppDzmTkclTT8YKO8c,230
@@ -7,7 +7,7 @@ runtimepy/mapping.py,sha256=VQK1vzmQVvYYKI85_II37-hIEbvgL3PzNy-WI6TTo80,5091
7
7
  runtimepy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  runtimepy/requirements.txt,sha256=PdID4t7w3qsEoNwrMR-SJoH5OQ9oIUcpesKJC4AiU64,124
9
9
  runtimepy/schemas.py,sha256=zTgxPm9DHZ0R_bmmOjNQMTXdtM_Hb1bE-Fog40jDCgg,839
10
- runtimepy/util.py,sha256=GuyIHVFGMS02OR6-O3LnlV3DqG5hj4-IUud0QM6WicA,1684
10
+ runtimepy/util.py,sha256=ZHSucNi-gbrcajoCv2dNjQs48dJPC3mTM_wZHx7AW1U,1719
11
11
  runtimepy/channel/__init__.py,sha256=pf0RJ5g37_FVV8xoUNgzFGuIfbZEYSBA_cQlJSDTPDo,4774
12
12
  runtimepy/channel/registry.py,sha256=nk36qM_Bf6qK6AFR0plaZHR1PU7b4LZqbQ0feJqk4lc,4784
13
13
  runtimepy/channel/environment/__init__.py,sha256=0Jj8g7Y4bdDvmWtzpegB9D4milGPhsZokoYxmps5zgU,1612
@@ -25,9 +25,9 @@ runtimepy/channel/event/__init__.py,sha256=9LCSNa1Iiwr6Q6JkwQGELDQ7rWfU_xjAMh6qM
25
25
  runtimepy/channel/event/header.py,sha256=eDRZgzzM5HZQ8QtV4DjyAsrAhEZyM7IfwqK6WB5ACEw,868
26
26
  runtimepy/codec/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  runtimepy/codec/protocol/__init__.py,sha256=Rg7RSKGn2UBpGMpwq1aCLUBA5h4pORdh53NfR7Cjw0U,1530
28
- runtimepy/codec/protocol/base.py,sha256=NRLB1ld0oB2IED5QRkwDwYsnHFG8gKtg3T7OHJ9_VkQ,10432
29
- runtimepy/codec/protocol/json.py,sha256=oiaJLCzptJ5uajnpO8EDYET8gIspZIrVuyLjLuAC5dw,4142
30
- runtimepy/codec/system/__init__.py,sha256=1Yy4RkNoh8tf6MTKZO1EszlCnE6jTevN2du4LU_-vxw,6933
28
+ runtimepy/codec/protocol/base.py,sha256=aIQCuUYPhe7-jgaYaoNzq3UU57lnBzrLqIr0H7fnHFc,10464
29
+ runtimepy/codec/protocol/json.py,sha256=gYGB_OEfZYySKQ_n3eDxYNs6Ku80FdawY5zDqjx9ctc,4315
30
+ runtimepy/codec/system/__init__.py,sha256=TRLfWTRPHtjJZHlRnQrEMGTYFzNK979vwSDLXr4nPsk,7308
31
31
  runtimepy/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  runtimepy/commands/all.py,sha256=jH2dsmkqyBFe_2ZlPFpko0UCMW3fFfJsuGIbeJFbDoQ,1619
33
33
  runtimepy/commands/arbiter.py,sha256=CtTMRYpqCAN3vWHkkr9jqWpoF7JGNXafKIBFmkarAfc,1567
@@ -118,7 +118,7 @@ runtimepy/data/static/woff2/CascadiaMono-Italic.woff2,sha256=S31PimDgq0GV7XMRV-Y
118
118
  runtimepy/data/static/woff2/CascadiaMono-Regular.woff2,sha256=hHPAFO0U10TCKBw-UofHN2BLjax9qNClzN9oWGKkQx0,143936
119
119
  runtimepy/data/static/woff2/README.md,sha256=flHwSRmDxd6OnWhzxmnXzwio1Mong5tB4d8VgieWCOs,289
120
120
  runtimepy/enum/__init__.py,sha256=WIBMOaogauR1u7mK-I4Z5BZUoWANU7alIlrz82QdCmY,5820
121
- runtimepy/enum/registry.py,sha256=EU7oUejI60kzrhdtzgWpnFYP8h4CFLy_fxvGTwq1Uvc,2631
121
+ runtimepy/enum/registry.py,sha256=SWCsyk7zLphlGC1doftT1z0AHwpdHRpffgyD4jgTs_A,3096
122
122
  runtimepy/enum/types.py,sha256=uQYGvaAJVm5tUdwxn_SLHkTZHJpEf7364rTSL27necA,1027
123
123
  runtimepy/message/__init__.py,sha256=X5PZqSPGhNT4MruaiQjN4MwJHhy8gV9W32QXyxgS9-E,3004
124
124
  runtimepy/message/handlers.py,sha256=He9NC7MCkaV2clKc8dTSZ_T8N2l3ATjaTFzBr9n1T34,3775
@@ -285,9 +285,9 @@ runtimepy/tui/task.py,sha256=nUZo9fuOC-k1Wpqdzkv9v1tQirCI28fZVgcC13Ijvus,1093
285
285
  runtimepy/tui/channels/__init__.py,sha256=evDaiIn-YS9uGhdo8ZGtP9VK1ek6sr_P1nJ9JuSET0o,4536
286
286
  runtimepy/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
287
287
  runtimepy/ui/controls.py,sha256=yvT7h3thbYaitsakcIAJ90EwKzJ4b-jnc6p3UuVf_XE,1241
288
- runtimepy-5.11.1.dist-info/licenses/LICENSE,sha256=yKBRwbO-cOPBrlpsZmJkkSa33DfY31aE8t7lZ0DwlUo,1071
289
- runtimepy-5.11.1.dist-info/METADATA,sha256=nTdV1gy7arFtuBI5Y-yZvzR5mao4DJwlu2dgKv14ra4,9395
290
- runtimepy-5.11.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
291
- runtimepy-5.11.1.dist-info/entry_points.txt,sha256=-btVBkYv7ybcopqZ_pRky-bEzu3vhbaG3W3Z7ERBiFE,51
292
- runtimepy-5.11.1.dist-info/top_level.txt,sha256=0jPmh6yqHyyJJDwEID-LpQly-9kQ3WRMjH7Lix8peLg,10
293
- runtimepy-5.11.1.dist-info/RECORD,,
288
+ runtimepy-5.11.2.dist-info/licenses/LICENSE,sha256=yKBRwbO-cOPBrlpsZmJkkSa33DfY31aE8t7lZ0DwlUo,1071
289
+ runtimepy-5.11.2.dist-info/METADATA,sha256=owly4GKtd8gZzMzY2TyKEJsTgDAjejgpmUvK4iNtlGM,9395
290
+ runtimepy-5.11.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
291
+ runtimepy-5.11.2.dist-info/entry_points.txt,sha256=-btVBkYv7ybcopqZ_pRky-bEzu3vhbaG3W3Z7ERBiFE,51
292
+ runtimepy-5.11.2.dist-info/top_level.txt,sha256=0jPmh6yqHyyJJDwEID-LpQly-9kQ3WRMjH7Lix8peLg,10
293
+ runtimepy-5.11.2.dist-info/RECORD,,