Add _short_str function for use in capnp_test_pycapnp.py
This commit is contained in:
@@ -163,9 +163,12 @@ cdef class _DynamicListReader:
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return printListReader(self.thisptr).flatten().cStr()
|
return printListReader(self.thisptr).flatten().cStr()
|
||||||
|
|
||||||
|
cpdef _short_str(self):
|
||||||
|
return strListReader(self.thisptr).cStr()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
# TODO: Print the list type.
|
# TODO: Print the list type.
|
||||||
return '<capnp list reader %s>' % strListReader(self.thisptr).cStr()
|
return '<capnp list reader %s>' % self._short_str()
|
||||||
|
|
||||||
cdef class _DynamicResizableListBuilder:
|
cdef class _DynamicResizableListBuilder:
|
||||||
"""Class for building growable Cap'n Proto Lists
|
"""Class for building growable Cap'n Proto Lists
|
||||||
@@ -308,9 +311,12 @@ cdef class _DynamicListBuilder:
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return printListBuilder(self.thisptr).flatten().cStr()
|
return printListBuilder(self.thisptr).flatten().cStr()
|
||||||
|
|
||||||
|
cpdef _short_str(self):
|
||||||
|
return strListBuilder(self.thisptr).cStr()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
# TODO: Print the list type.
|
# TODO: Print the list type.
|
||||||
return '<capnp list builder %s>' % strListBuilder(self.thisptr).cStr()
|
return '<capnp list builder %s>' % self._short_str()
|
||||||
|
|
||||||
cdef class _List_NestedNode_Reader:
|
cdef class _List_NestedNode_Reader:
|
||||||
cdef List[C_Node.NestedNode].Reader thisptr
|
cdef List[C_Node.NestedNode].Reader thisptr
|
||||||
@@ -534,8 +540,11 @@ cdef class _DynamicStructReader:
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return printStructReader(self.thisptr).flatten().cStr()
|
return printStructReader(self.thisptr).flatten().cStr()
|
||||||
|
|
||||||
|
cpdef _short_str(self):
|
||||||
|
return strStructReader(self.thisptr).cStr()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<%s reader %s>' % (self.schema.node.displayName, strStructReader(self.thisptr).cStr())
|
return '<%s reader %s>' % (self.schema.node.displayName, self._short_str())
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return _to_dict(self)
|
return _to_dict(self)
|
||||||
@@ -751,8 +760,11 @@ cdef class _DynamicStructBuilder:
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return printStructBuilder(self.thisptr).flatten().cStr()
|
return printStructBuilder(self.thisptr).flatten().cStr()
|
||||||
|
|
||||||
|
cpdef _short_str(self):
|
||||||
|
return strStructBuilder(self.thisptr).cStr()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<%s builder %s>' % (self.schema.node.displayName, strStructBuilder(self.thisptr).cStr())
|
return '<%s builder %s>' % (self.schema.node.displayName, self._short_str)
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return _to_dict(self)
|
return _to_dict(self)
|
||||||
|
|||||||
@@ -7,15 +7,8 @@ import test_capnp
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def format_decode(val):
|
|
||||||
val = val.replace('\n ', '')
|
|
||||||
val = val.replace('( ', '(')
|
|
||||||
val = val.replace(' )', ')')
|
|
||||||
|
|
||||||
return val
|
|
||||||
|
|
||||||
def decode(name):
|
def decode(name):
|
||||||
print format_decode(str(getattr(test_capnp, name)))
|
print getattr(test_capnp, name)._short_str()
|
||||||
|
|
||||||
def encode(name):
|
def encode(name):
|
||||||
val = getattr(test_capnp, name)
|
val = getattr(test_capnp, name)
|
||||||
|
|||||||
Reference in New Issue
Block a user