[project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-88]

add Message.rewind()
add rewind() method to Message, which just resets the pointer so you can
start reading from the beginning again.  this is useful for some tests.
This commit is contained in:
Robey Pointer 2004-09-25 21:32:53 +00:00
parent 12287b3e0e
commit 3e644a94f1
2 changed files with 12 additions and 1 deletions

View File

@ -61,6 +61,13 @@ class Message (object):
"""
return 'paramiko.Message(' + repr(self.packet) + ')'
def rewind(self):
"""
Rewind the message to the beginning as if no items had been parsed
out of it yet.
"""
self.idx = 0
def get_remainder(self):
"""
Return the bytes of this Message that haven't already been parsed and

View File

@ -95,4 +95,8 @@ class MessageTest (unittest.TestCase):
self.assertEquals(msg.get_mpint(), 0x1122334455L)
self.assertEquals(msg.get_so_far(), self.__d[:13])
self.assertEquals(msg.get_remainder(), self.__d[13:])
msg.rewind()
self.assertEquals(msg.get_int(), 5)
self.assertEquals(msg.get_so_far(), self.__d[:4])
self.assertEquals(msg.get_remainder(), self.__d[4:])