Format init

This commit is contained in:
Jeff Forcier 2014-02-24 17:19:38 -08:00
parent e2ac82c47c
commit a00316af15
1 changed files with 13 additions and 13 deletions

View File

@ -127,30 +127,30 @@ class Transport (threading.Thread):
def __init__(self, sock): def __init__(self, sock):
""" """
Create a new SSH session over an existing socket, or socket-like Create a new SSH session over an existing socket, or socket-like
object. This only creates the Transport object; it doesn't begin the object. This only creates the `.Transport` object; it doesn't begin the
SSH session yet. Use `connect` or `start_client` to begin a client SSH session yet. Use `connect` or `start_client` to begin a client
session, or `start_server` to begin a server session. session, or `start_server` to begin a server session.
If the object is not actually a socket, it must have the following If the object is not actually a socket, it must have the following
methods: methods:
- ``send(str)``: Writes from 1 to ``len(str)`` bytes, and
returns an int representing the number of bytes written. Returns - ``send(str)``: Writes from 1 to ``len(str)`` bytes, and returns an
0 or raises ``EOFError`` if the stream has been closed. int representing the number of bytes written. Returns
- ``recv(int)``: Reads from 1 to ``int`` bytes and returns them as a 0 or raises ``EOFError`` if the stream has been closed.
string. Returns 0 or raises ``EOFError`` if the stream has been - ``recv(int)``: Reads from 1 to ``int`` bytes and returns them as a
closed. string. Returns 0 or raises ``EOFError`` if the stream has been
- ``close()``: Closes the socket. closed.
- ``settimeout(n)``: Sets a (float) timeout on I/O operations. - ``close()``: Closes the socket.
- ``settimeout(n)``: Sets a (float) timeout on I/O operations.
For ease of use, you may also pass in an address (as a tuple) or a host For ease of use, you may also pass in an address (as a tuple) or a host
string as the ``sock`` argument. (A host string is a hostname with an string as the ``sock`` argument. (A host string is a hostname with an
optional port (separated by ``":"``) which will be converted into a optional port (separated by ``":"``) which will be converted into a
tuple of ``(hostname, port)``.) A socket will be connected to this tuple of ``(hostname, port)``.) A socket will be connected to this
address and used for communication. Exceptions from the ``socket`` call address and used for communication. Exceptions from the ``socket``
may be thrown in this case. call may be thrown in this case.
:param sock: a socket or socket-like object to create the session over. :param socket sock: a socket or socket-like object to create the session over.
:type sock: socket
""" """
if isinstance(sock, (str, unicode)): if isinstance(sock, (str, unicode)):
# convert "host:port" into (host, port) # convert "host:port" into (host, port)