mirror of
https://github.com/iKarith/cppo-ng.git
synced 2025-04-08 23:38:09 +00:00
Hexdump, better __str__ for ByteBuffer
We broke str(ByteBuffer) with the util.py commit, but having that return a possibly megabytes-long string was stupid anyway. It now returns a string just indicating that it's not really a printable thing rather than the still probably extremely long repr(). Added a hexdump function to call util.hexdump cleanly. This is really only here for debugging. I can imagine a lot of things you could do to account for possibilities later on, but YAGNI applies (including that if you do need it, you can add it then.)
This commit is contained in:
parent
ae199947b0
commit
ed6156c3c6
@ -126,10 +126,14 @@ class ByteBuffer(BufferType):
|
||||
return 'ByteBuffer({_buf}, {_changed}, {_locked})'.format_map(
|
||||
vars(self))
|
||||
|
||||
def __str__(self):
|
||||
"""Return str(self)
|
||||
def __str__(self) -> str:
|
||||
"""Implement str(self)"""
|
||||
return '<ByteBuffer of {} bytes>'.format(len(self._buf))
|
||||
|
||||
This will be a very long string containing newlines for any buffer of
|
||||
non-trivial length
|
||||
def hexdump(self, *args: List, **kwargs: Dict) -> None:
|
||||
"""Performas a canonical hexdump of self.
|
||||
|
||||
Args:
|
||||
Any for blocksfree.util.hexdump, see that function for details.
|
||||
"""
|
||||
return '\n'.join(gen_hexdump(self._buf))
|
||||
util.hexdump(self._buf, *args, **kwargs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user