runtimepy 5.11.0__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=c4e165f8c6309dd6819689f0262cf92d
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.0"
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,13 +102,22 @@ 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
- new_type = Protocol(self._enums)
105
- self.custom[self._name(name, *namespace, check_available=True)] = (
106
- new_type
113
+ resolved = self._name(name, *namespace, check_available=True)
114
+ new_type = Protocol(
115
+ self._enums,
116
+ alias=resolved,
117
+ identifier=self.custom_ids(),
118
+ byte_order=byte_order,
107
119
  )
120
+ self.custom[resolved] = new_type
108
121
  return new_type
109
122
 
110
123
  def get_protocol(
@@ -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
@@ -37,8 +37,9 @@ class BaseIntPrimitive(PrimitiveIsCloseMixin[int]):
37
37
  """Set this primitive to a random integer."""
38
38
 
39
39
  assert self.kind.int_bounds is not None
40
- result = self.kind.int_bounds.random()
41
- self.set_value(result, timestamp_ns=timestamp_ns)
40
+ self.set_value(
41
+ self.kind.int_bounds.random(), timestamp_ns=timestamp_ns
42
+ )
42
43
 
43
44
  def increment(self, amount: int = 1, timestamp_ns: int = None) -> int:
44
45
  """Increment this primitive by some amount and return the new value."""
@@ -176,13 +176,20 @@ class Serializable(ABC):
176
176
 
177
177
  result = []
178
178
 
179
+ # Copy the chain element before it becomes part of the current chain if
180
+ # an array is created.
181
+ copy_base = None
182
+ if array_length is not None:
183
+ copy_base = chain.copy()
184
+
179
185
  self.end.assign(chain)
180
186
  result.append(chain)
181
187
 
182
188
  # Add additional array elements as copies.
183
189
  if array_length is not None:
190
+ assert copy_base is not None
184
191
  for _ in range(array_length - 1):
185
- inst = chain.copy()
192
+ inst = copy_base.copy()
186
193
  self.end.assign(inst)
187
194
  result.append(inst)
188
195
 
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.0
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
@@ -17,11 +17,11 @@ Classifier: License :: OSI Approved :: MIT License
17
17
  Requires-Python: >=3.12
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
- Requires-Dist: svgen>=0.7.4
21
- Requires-Dist: websockets
22
- Requires-Dist: vcorelib>=3.5.1
23
20
  Requires-Dist: psutil
21
+ Requires-Dist: websockets
24
22
  Requires-Dist: aiofiles
23
+ Requires-Dist: vcorelib>=3.5.1
24
+ Requires-Dist: svgen>=0.7.4
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=12eb2a9d91dea3ae83e38a864f6cab4b
53
+ hash=8a7622d7187fa17bfcc479f8f6f78d1a
54
54
  =====================================
55
55
  -->
56
56
 
57
- # runtimepy ([5.11.0](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=_iqys5Hal_wrIAXPN1-B9DZRorvDPmYsRk12jBL_9hg,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=cW_Y-hC9GgIXhFQBmNO0Lx8HdFNh-wxx1mTck14PFzw,6913
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
@@ -236,7 +236,7 @@ runtimepy/primitives/bool.py,sha256=lATPgb1e62rjLn5XlJX8lP3tVYR3DlxV8RT9HpOMdT0,
236
236
  runtimepy/primitives/byte_order.py,sha256=80mMk1Sj_l49XvAtvrPmoYFpFYSM1HgYuwR2-P7os3Q,767
237
237
  runtimepy/primitives/evaluation.py,sha256=0N7mT8uoiJaY-coF2PeEXU2WO-FmbyN2Io9_EaghO9Q,4657
238
238
  runtimepy/primitives/float.py,sha256=6vzNKnnLzzM4vP10V4E0PHZQH6vTvIl34pId1oFtlqc,2146
239
- runtimepy/primitives/int.py,sha256=zaZZjVSuDtZsOWRYt8eN38pPVGZfj7y4IyrfQ1rVKTk,3620
239
+ runtimepy/primitives/int.py,sha256=Ia2vtzXXfBb8fj1mgwu_PFpblrL2qzsN4Qwjvk5NhT4,3618
240
240
  runtimepy/primitives/scaling.py,sha256=Vtxp2CSBahqPp4i2-IS4wjbcC023xwf-dqZMbYWf3V4,1144
241
241
  runtimepy/primitives/string.py,sha256=ic5VKhXCSIwEOUfqIb1VUpZPwjdAcBul-cLLIihVkQI,2532
242
242
  runtimepy/primitives/array/__init__.py,sha256=ZVJt4810hTFYMdolY_R75lRRHHaNKxZ4comBvuK_69E,8956
@@ -245,7 +245,7 @@ runtimepy/primitives/field/fields.py,sha256=jDNi1tl2Xc3GBmt6QJuqxbhP8MtxgertGbPF
245
245
  runtimepy/primitives/field/manager/__init__.py,sha256=BCRi6-_5OOJ8kz78JHkiLp8cZ71KA1uiF2zq5FFe9js,2586
246
246
  runtimepy/primitives/field/manager/base.py,sha256=EyWs5D9_reKOTLkh8PuW45ySjCh31fY_qrtFIcmIOV4,6914
247
247
  runtimepy/primitives/serializable/__init__.py,sha256=R9_derxnK1OCaYyqBZA4CCjPkXCBw6InkE8-3Zy75Uk,399
248
- runtimepy/primitives/serializable/base.py,sha256=ij-9WaUZIMljS1iztciuz0XTWJdlKuyNjvf5nu0HxrE,5471
248
+ runtimepy/primitives/serializable/base.py,sha256=EIj7Ao0sZaXCXgZari35kimjkr3SzFWGy3rNjxgsv1E,5727
249
249
  runtimepy/primitives/serializable/fixed.py,sha256=rhr6uVbo0Lvazk4fLI7iei-vVNEwP1J8-LoUjW1NaMI,1077
250
250
  runtimepy/primitives/serializable/framer.py,sha256=rsoGQz6vD7v_EMu67aqxVqbvmbs6hjytXZ8dHLBM0SQ,1815
251
251
  runtimepy/primitives/serializable/prefixed.py,sha256=oQXW0pGRovKolheL5ZL2m9aNVMCtKTAi5OlC9KW0iKI,2855
@@ -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.0.dist-info/licenses/LICENSE,sha256=yKBRwbO-cOPBrlpsZmJkkSa33DfY31aE8t7lZ0DwlUo,1071
289
- runtimepy-5.11.0.dist-info/METADATA,sha256=mj58S6d33EOyEgeZSpDwo9UU5imTeKZ2r5pRdrkguFk,9395
290
- runtimepy-5.11.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
291
- runtimepy-5.11.0.dist-info/entry_points.txt,sha256=-btVBkYv7ybcopqZ_pRky-bEzu3vhbaG3W3Z7ERBiFE,51
292
- runtimepy-5.11.0.dist-info/top_level.txt,sha256=0jPmh6yqHyyJJDwEID-LpQly-9kQ3WRMjH7Lix8peLg,10
293
- runtimepy-5.11.0.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,,