summaryrefslogtreecommitdiff
path: root/paramiko/message.py
diff options
context:
space:
mode:
authorOlle Lundberg <olle.lundberg@klarna.com>2014-01-23 11:32:59 +0100
committerOlle Lundberg <olle.lundberg@klarna.com>2014-01-23 11:32:59 +0100
commit24635609dc5ab8aff2e7fa3f34c4993cbc424579 (patch)
tree7be1e6ee8e6df7e90c188cd8949cbb8fba9e372e /paramiko/message.py
parentdde21a7de09bd92a6a362a26009a56a942b3d246 (diff)
downloadparamiko-24635609dc5ab8aff2e7fa3f34c4993cbc424579.tar.gz
Epydoc -> Sphinx.
Diffstat (limited to 'paramiko/message.py')
-rw-r--r--paramiko/message.py98
1 files changed, 49 insertions, 49 deletions
diff --git a/paramiko/message.py b/paramiko/message.py
index c0e8692b..85fb3c09 100644
--- a/paramiko/message.py
+++ b/paramiko/message.py
@@ -28,9 +28,9 @@ from paramiko import util
class Message (object):
"""
- An SSH2 I{Message} is a stream of bytes that encodes some combination of
+ An SSH2 Message is a stream of bytes that encodes some combination of
strings, integers, bools, and infinite-precision integers (known in python
- as I{long}s). This class builds or breaks down such a byte stream.
+ as longs). This class builds or breaks down such a byte stream.
Normally you don't need to deal with anything this low-level, but it's
exposed for people implementing custom extensions, or features that
@@ -41,9 +41,9 @@ class Message (object):
"""
Create a new SSH2 Message.
- @param content: the byte stream to use as the Message content (passed
+ :param content: the byte stream to use as the Message content (passed
in only when decomposing a Message).
- @type content: string
+ :type content: string
"""
if content != None:
self.packet = cStringIO.StringIO(content)
@@ -54,8 +54,8 @@ class Message (object):
"""
Return the byte stream content of this Message, as a string.
- @return: the contents of this Message.
- @rtype: string
+ :return: the contents of this Message.
+ :rtype: string
"""
return self.packet.getvalue()
@@ -63,7 +63,7 @@ class Message (object):
"""
Returns a string representation of this object, for debugging.
- @rtype: string
+ :rtype: string
"""
return 'paramiko.Message(' + repr(self.packet.getvalue()) + ')'
@@ -79,8 +79,8 @@ class Message (object):
Return the bytes of this Message that haven't already been parsed and
returned.
- @return: a string of the bytes not parsed yet.
- @rtype: string
+ :return: a string of the bytes not parsed yet.
+ :rtype: string
"""
position = self.packet.tell()
remainder = self.packet.read()
@@ -91,10 +91,10 @@ class Message (object):
"""
Returns the bytes of this Message that have been parsed and returned.
The string passed into a Message's constructor can be regenerated by
- concatenating C{get_so_far} and L{get_remainder}.
+ concatenating ``get_so_far`` and :class:`get_remainder`.
- @return: a string of the bytes parsed so far.
- @rtype: string
+ :return: a string of the bytes parsed so far.
+ :rtype: string
"""
position = self.packet.tell()
self.rewind()
@@ -102,12 +102,12 @@ class Message (object):
def get_bytes(self, n):
"""
- Return the next C{n} bytes of the Message, without decomposing into
+ Return the next ``n`` bytes of the Message, without decomposing into
an int, string, etc. Just the raw bytes are returned.
- @return: a string of the next C{n} bytes of the Message, or a string
- of C{n} zero bytes, if there aren't C{n} bytes remaining.
- @rtype: string
+ :return: a string of the next ``n`` bytes of the Message, or a string
+ of ``n`` zero bytes, if there aren't ``n`` bytes remaining.
+ :rtype: string
"""
b = self.packet.read(n)
max_pad_size = 1<<20 # Limit padding to 1 MB
@@ -118,11 +118,11 @@ class Message (object):
def get_byte(self):
"""
Return the next byte of the Message, without decomposing it. This
- is equivalent to L{get_bytes(1)<get_bytes>}.
+ is equivalent to :class:`get_bytes(1)<get_bytes>`.
- @return: the next byte of the Message, or C{'\000'} if there aren't
+ :return: the next byte of the Message, or ``'\000'`` if there aren't
any bytes remaining.
- @rtype: string
+ :rtype: string
"""
return self.get_bytes(1)
@@ -130,8 +130,8 @@ class Message (object):
"""
Fetch a boolean from the stream.
- @return: C{True} or C{False} (from the Message).
- @rtype: bool
+ :return: ``True`` or ``False`` (from the Message).
+ :rtype: bool
"""
b = self.get_bytes(1)
return b != '\x00'
@@ -140,8 +140,8 @@ class Message (object):
"""
Fetch an int from the stream.
- @return: a 32-bit unsigned integer.
- @rtype: int
+ :return: a 32-bit unsigned integer.
+ :rtype: int
"""
return struct.unpack('>I', self.get_bytes(4))[0]
@@ -149,8 +149,8 @@ class Message (object):
"""
Fetch a 64-bit int from the stream.
- @return: a 64-bit unsigned integer.
- @rtype: long
+ :return: a 64-bit unsigned integer.
+ :rtype: long
"""
return struct.unpack('>Q', self.get_bytes(8))[0]
@@ -158,8 +158,8 @@ class Message (object):
"""
Fetch a long int (mpint) from the stream.
- @return: an arbitrary-length integer.
- @rtype: long
+ :return: an arbitrary-length integer.
+ :rtype: long
"""
return util.inflate_long(self.get_string())
@@ -169,8 +169,8 @@ class Message (object):
contain unprintable characters. (It's not unheard of for a string to
contain another byte-stream Message.)
- @return: a string.
- @rtype: string
+ :return: a string.
+ :rtype: string
"""
return self.get_bytes(self.get_int())
@@ -179,8 +179,8 @@ class Message (object):
Fetch a list of strings from the stream. These are trivially encoded
as comma-separated values in a string.
- @return: a list of strings.
- @rtype: list of strings
+ :return: a list of strings.
+ :rtype: list of strings
"""
return self.get_string().split(',')
@@ -188,8 +188,8 @@ class Message (object):
"""
Write bytes to the stream, without any formatting.
- @param b: bytes to add
- @type b: str
+ :param b: bytes to add
+ :type b: str
"""
self.packet.write(b)
return self
@@ -198,8 +198,8 @@ class Message (object):
"""
Write a single byte to the stream, without any formatting.
- @param b: byte to add
- @type b: str
+ :param b: byte to add
+ :type b: str
"""
self.packet.write(b)
return self
@@ -208,8 +208,8 @@ class Message (object):
"""
Add a boolean value to the stream.
- @param b: boolean value to add
- @type b: bool
+ :param b: boolean value to add
+ :type b: bool
"""
if b:
self.add_byte('\x01')
@@ -221,8 +221,8 @@ class Message (object):
"""
Add an integer to the stream.
- @param n: integer to add
- @type n: int
+ :param n: integer to add
+ :type n: int
"""
self.packet.write(struct.pack('>I', n))
return self
@@ -231,8 +231,8 @@ class Message (object):
"""
Add a 64-bit int to the stream.
- @param n: long int to add
- @type n: long
+ :param n: long int to add
+ :type n: long
"""
self.packet.write(struct.pack('>Q', n))
return self
@@ -242,8 +242,8 @@ class Message (object):
Add a long int to the stream, encoded as an infinite-precision
integer. This method only works on positive numbers.
- @param z: long int to add
- @type z: long
+ :param z: long int to add
+ :type z: long
"""
self.add_string(util.deflate_long(z))
return self
@@ -252,8 +252,8 @@ class Message (object):
"""
Add a string to the stream.
- @param s: string to add
- @type s: str
+ :param s: string to add
+ :type s: str
"""
self.add_int(len(s))
self.packet.write(s)
@@ -265,8 +265,8 @@ class Message (object):
a single string of values separated by commas. (Yes, really, that's
how SSH2 does it.)
- @param l: list of strings to add
- @type l: list(str)
+ :param l: list of strings to add
+ :type l: list(str)
"""
self.add_string(','.join(l))
return self
@@ -293,8 +293,8 @@ class Message (object):
Add a sequence of items to the stream. The values are encoded based
on their type: str, int, bool, list, or long.
- @param seq: the sequence of items
- @type seq: sequence
+ :param seq: the sequence of items
+ :type seq: sequence
@bug: longs are encoded non-deterministically. Don't use this method.
"""