canoser
Advanced tools
| Metadata-Version: 2.1 | ||
| Name: canoser | ||
| Version: 0.7.6 | ||
| Version: 0.7.7 | ||
| Summary: A python implementation of the LCS(Libra Canonical Serialization) for the Libra network. | ||
@@ -5,0 +5,0 @@ Home-page: https://github.com/yuan-xy/canoser-python.git |
+2
-7
@@ -15,3 +15,4 @@ from canoser.cursor import Cursor | ||
| def to_json_serializable(cls_or_obj, value) | ||
| def to_json_serializable(obj) | ||
| def to_json_serializable(acls, value) | ||
| """ | ||
@@ -32,7 +33,1 @@ | ||
| def __str__(self): | ||
| return self.to_json(indent=2) | ||
| def to_json(self, sort_keys=False, indent=4): | ||
| amap = self.to_json_serializable() | ||
| return json.dumps(amap, sort_keys=sort_keys, indent=indent) |
@@ -45,3 +45,6 @@ from canoser.base import Base | ||
| def __getattr__(self, name): | ||
| return self._index == self.__class__.get_index(name) | ||
| try: | ||
| return self._index == self.__class__.get_index(name) | ||
| except TypeError: | ||
| return super().__getattr__(self, name) | ||
@@ -48,0 +51,0 @@ def __setattr__(self, name, value): |
+16
-2
| from canoser.base import Base | ||
| from canoser.cursor import Cursor | ||
| from canoser.types import type_mapping | ||
| import json | ||
| class TypedProperty: | ||
@@ -101,6 +103,18 @@ def __init__(self, name, expected_type): | ||
| value = getattr(self, name) | ||
| atype = type_mapping(atype) | ||
| amap[name] = atype.to_json_serializable(value) | ||
| if isinstance(value, TypedProperty): | ||
| amap[name] = None | ||
| else: | ||
| atype = type_mapping(atype) | ||
| amap[name] = atype.to_json_serializable(value) | ||
| return amap | ||
| def __str__(self): | ||
| return self.to_json(indent=2) | ||
| def __repr__(self): | ||
| return self.__class__.__qualname__ + self.to_json(indent=2) | ||
| def to_json(self, sort_keys=False, indent=4): | ||
| amap = self.to_json_serializable() | ||
| return json.dumps(amap, sort_keys=sort_keys, indent=indent) | ||
@@ -1,1 +0,1 @@ | ||
| version = "0.7.6" | ||
| version = "0.7.7" |
+1
-1
| Metadata-Version: 2.1 | ||
| Name: canoser | ||
| Version: 0.7.6 | ||
| Version: 0.7.7 | ||
| Summary: A python implementation of the LCS(Libra Canonical Serialization) for the Libra network. | ||
@@ -5,0 +5,0 @@ Home-page: https://github.com/yuan-xy/canoser-python.git |
@@ -31,2 +31,7 @@ import pytest | ||
| t_arg = TransactionArgument('U64', 2) | ||
| assert hasattr(t_arg, 'value') | ||
| assert hasattr(t_arg, 'U64') | ||
| assert hasattr(t_arg, 'Address') | ||
| assert hasattr(t_arg, '__str__') | ||
| assert hasattr(t_arg, 'to_proto') == False | ||
| assert t_arg.index == 0 | ||
@@ -33,0 +38,0 @@ assert t_arg.value == 2 |
@@ -35,2 +35,3 @@ from canoser import * | ||
| actual_output = Address2.encode(input) | ||
| assert bytes(input) == actual_output | ||
| assert bytes(expected_output) == actual_output | ||
@@ -37,0 +38,0 @@ |
+14
-1
@@ -88,2 +88,12 @@ import pytest | ||
| class MapS2(Struct): | ||
| _fields = [('counters', {Uint16 : Uint64})] | ||
| def test_map_empty(): | ||
| x = MapS2({}) | ||
| sx = x.serialize() | ||
| x2 = MapS2.deserialize(sx) | ||
| assert x.counters == x2.counters | ||
| class ChineseMap(Struct): | ||
@@ -151,2 +161,5 @@ _fields = [('kvs', {str : str})] | ||
| def test_print_null_field(): | ||
| x = Uint128S() | ||
| print(x) | ||
| print(x.__repr__()) |
| from canoser import * | ||
| from canoser.types import type_mapping | ||
| import pdb | ||
@@ -180,1 +181,5 @@ import pytest | ||
| def test_type_mapping(): | ||
| atype = {Uint16: Uint64} | ||
| mtype = type_mapping(atype) | ||
| print(mtype) |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
105694
0.98%1530
2.07%