jamcodec 0.1.5__tar.gz → 0.1.6__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.
- {jamcodec-0.1.5 → jamcodec-0.1.6}/PKG-INFO +1 -1
- {jamcodec-0.1.5 → jamcodec-0.1.6}/jamcodec/types.py +17 -17
- {jamcodec-0.1.5 → jamcodec-0.1.6}/jamcodec.egg-info/PKG-INFO +1 -1
- {jamcodec-0.1.5 → jamcodec-0.1.6}/LICENSE +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/README.md +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/jamcodec/__init__.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/jamcodec/base.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/jamcodec/constants.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/jamcodec/exceptions.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/jamcodec/mixins.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/jamcodec.egg-info/SOURCES.txt +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/jamcodec.egg-info/dependency_links.txt +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/jamcodec.egg-info/requires.txt +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/jamcodec.egg-info/top_level.txt +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/pyproject.toml +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/requirements.txt +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/setup.cfg +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_array.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_bitarray.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_bitvec.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_boolean.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_bounded_vec.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_bytes.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_compact.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_enum.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_float.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_hashmap.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_integer.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_map.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_mixins.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_option.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_scale_types.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_scalebytes.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_string.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_struct.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_tuple.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_varint.py +0 -0
- {jamcodec-0.1.5 → jamcodec-0.1.6}/test/test_vec.py +0 -0
|
@@ -197,18 +197,18 @@ class Struct(JamCodecTypeDef):
|
|
|
197
197
|
|
|
198
198
|
def encode(self, value: dict) -> JamBytes:
|
|
199
199
|
|
|
200
|
-
data =
|
|
200
|
+
data = bytearray()
|
|
201
201
|
for name, scale_obj in self.arguments.items():
|
|
202
202
|
|
|
203
203
|
if name not in value:
|
|
204
204
|
raise ScaleEncodeException(f'Argument "{name}" of Struct is missing in given value')
|
|
205
205
|
|
|
206
|
-
data
|
|
206
|
+
data.extend(scale_obj.encode(value[name]).data)
|
|
207
207
|
|
|
208
208
|
if value[name] and issubclass(value[name].__class__, JamCodecType):
|
|
209
209
|
value[name] = value[name].serialize()
|
|
210
210
|
|
|
211
|
-
return data
|
|
211
|
+
return JamBytes(data)
|
|
212
212
|
|
|
213
213
|
def decode(self, data) -> dict:
|
|
214
214
|
value = {}
|
|
@@ -277,11 +277,11 @@ class Tuple(JamCodecTypeDef):
|
|
|
277
277
|
if type(value) is not tuple:
|
|
278
278
|
value = (value,)
|
|
279
279
|
|
|
280
|
-
data =
|
|
280
|
+
data = bytearray()
|
|
281
281
|
for idx, scale_obj in enumerate(self.values):
|
|
282
282
|
|
|
283
|
-
data
|
|
284
|
-
return data
|
|
283
|
+
data.extend(scale_obj.encode(value[idx]).data)
|
|
284
|
+
return JamBytes(data)
|
|
285
285
|
|
|
286
286
|
def decode(self, data: JamBytes) -> tuple:
|
|
287
287
|
value = ()
|
|
@@ -615,17 +615,17 @@ class Vec(JamCodecTypeDef):
|
|
|
615
615
|
return Bytes.encode(value)
|
|
616
616
|
|
|
617
617
|
# Encode length of Vec
|
|
618
|
-
data = VarInt64.encode(len(value))
|
|
618
|
+
data = VarInt64.encode(len(value)).data
|
|
619
619
|
|
|
620
620
|
for idx, item in enumerate(value):
|
|
621
621
|
if type(item) is JamBytes:
|
|
622
|
-
data
|
|
622
|
+
data.extend(item.data)
|
|
623
623
|
else:
|
|
624
|
-
data
|
|
624
|
+
data.extend(self.type_def.encode(item).data)
|
|
625
625
|
if item and issubclass(item.__class__, JamCodecType):
|
|
626
626
|
value[idx] = item.serialize()
|
|
627
627
|
|
|
628
|
-
return data
|
|
628
|
+
return JamBytes(data)
|
|
629
629
|
|
|
630
630
|
def decode(self, data: JamBytes) -> Union[list, bytes]:
|
|
631
631
|
|
|
@@ -823,7 +823,7 @@ class Array(JamCodecTypeDef):
|
|
|
823
823
|
|
|
824
824
|
return JamBytes(value)
|
|
825
825
|
else:
|
|
826
|
-
data =
|
|
826
|
+
data = bytearray()
|
|
827
827
|
|
|
828
828
|
if type(value) is not list:
|
|
829
829
|
raise ScaleEncodeException("Value must be of type list")
|
|
@@ -832,9 +832,9 @@ class Array(JamCodecTypeDef):
|
|
|
832
832
|
raise ScaleEncodeException("Length of list does not match size of array")
|
|
833
833
|
|
|
834
834
|
for item in value:
|
|
835
|
-
data
|
|
835
|
+
data.extend(self.type_def.encode(item).data)
|
|
836
836
|
|
|
837
|
-
return data
|
|
837
|
+
return JamBytes(data)
|
|
838
838
|
|
|
839
839
|
def decode(self, data: JamBytes) -> Union[list, bytes]:
|
|
840
840
|
if self.type_def is U8:
|
|
@@ -1042,13 +1042,13 @@ class Map(JamCodecTypeDef):
|
|
|
1042
1042
|
value = sorted(value)
|
|
1043
1043
|
|
|
1044
1044
|
# Encode length of Vec
|
|
1045
|
-
data = VarInt64.encode(len(value))
|
|
1045
|
+
data = VarInt64.encode(len(value)).data
|
|
1046
1046
|
|
|
1047
1047
|
for item_key, item_value in value:
|
|
1048
|
-
data
|
|
1049
|
-
data
|
|
1048
|
+
data.extend(self.key_def.encode(item_key).data)
|
|
1049
|
+
data.extend(self.value_def.encode(item_value).data)
|
|
1050
1050
|
|
|
1051
|
-
return data
|
|
1051
|
+
return JamBytes(data)
|
|
1052
1052
|
|
|
1053
1053
|
def decode(self, data: JamBytes) -> list:
|
|
1054
1054
|
# Decode length of Map
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|