diff options
author | Robey Pointer <robey@lag.net> | 2004-09-11 20:35:19 +0000 |
---|---|---|
committer | Robey Pointer <robey@lag.net> | 2004-09-11 20:35:19 +0000 |
commit | 026425c117d37793450a9dc4bfcb05a55fbde888 (patch) | |
tree | 7ab23bd98535bd73c09affad4c76568148245c9c | |
parent | caa1f881056b8378cb7058bf98769d2e36b59ada (diff) |
[project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-79]
Message.add() can take many args
a bit of cleanup to Message: add() can now take any number of params, and
will add them all in order (using type guessing).
-rw-r--r-- | paramiko/message.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/paramiko/message.py b/paramiko/message.py index a230f4eb..f46ab3d0 100644 --- a/paramiko/message.py +++ b/paramiko/message.py @@ -59,7 +59,7 @@ class Message (object): @rtype: string """ - return 'Message(' + repr(self.packet) + ')' + return 'paramiko.Message(' + repr(self.packet) + ')' def get_remainder(self): """ @@ -116,10 +116,7 @@ class Message (object): @rtype: bool """ b = self.get_bytes(1) - if b == '\x00': - return False - else: - return True + return b != '\x00' def get_int(self): """ @@ -233,19 +230,23 @@ class Message (object): self.packet = self.packet + out return self - def add(self, i): - if type(i) == types.StringType: + def _add(self, i): + if type(i) is str: return self.add_string(i) - elif type(i) == types.IntType: + elif type(i) is int: return self.add_int(i) - elif type(i) == types.LongType: + elif type(i) is long: if i > 0xffffffffL: return self.add_mpint(i) else: return self.add_int(i) elif type(i) is bool: return self.add_boolean(i) - elif type(i) == types.ListType: + elif type(i) is list: return self.add_list(i) else: raise exception('Unknown type') + + def add(self, *seq): + for item in seq: + self._add(item) |