changeset 552b79ec155d in /home/hg/repos/gajim

details:http://hg.gajim.org/gajim?cmd=changeset;node=552b79ec155d
description: Last portion of doc-string and formatting refactoring

diffstat:

 src/common/xmpp/stringprepare.py |   51 +++++++-----
 src/common/xmpp/tls_nb.py        |   50 +++++++----
 src/common/xmpp/transports_nb.py |  174 
++++++++++++++++++++++++-------------------
 3 files changed, 159 insertions(+), 116 deletions(-)

diffs (truncated from 610 to 300 lines):

diff -r 67acb768d786 -r 552b79ec155d src/common/xmpp/stringprepare.py
--- a/src/common/xmpp/stringprepare.py  Thu Nov 26 17:46:48 2009 +0200
+++ b/src/common/xmpp/stringprepare.py  Thu Nov 26 18:12:52 2009 +0200
@@ -26,16 +26,26 @@
 from encodings import idna
 
 class ILookupTable:
-       """ Interface for character lookup classes. """
+       """
+       Interface for character lookup classes
+       """
 
        def lookup(self, c):
-               """ Return whether character is in this table. """
+               """
+               Return whether character is in this table
+               """
+               pass
 
 class IMappingTable:
-       """ Interface for character mapping classes. """
+       """
+       Interface for character mapping classes
+       """
 
        def map(self, c):
-               """ Return mapping for character. """
+               """
+               Return mapping for character
+               """
+               pass
 
 class LookupTableFromFunction:
 
@@ -75,8 +85,8 @@
                        return c
 
 class Profile:
-       def __init__(self, mappings=[],  normalize=True, prohibiteds=[],
-                                               check_unassigneds=True, 
check_bidi=True):
+       def __init__(self, mappings=[], normalize=True, prohibiteds=[],
+                       check_unassigneds=True, check_bidi=True):
                self.mappings = mappings
                self.normalize = normalize
                self.prohibiteds = prohibiteds
@@ -140,24 +150,25 @@
 
 
 class NamePrep:
-       """ Implements preparation of internationalized domain names.
+       """
+       Implements preparation of internationalized domain names
 
-               This class implements preparing internationalized domain names 
using the
-               rules defined in RFC 3491, section 4 (Conversion operations).
+       This class implements preparing internationalized domain names using the
+       rules defined in RFC 3491, section 4 (Conversion operations).
 
-               We do not perform step 4 since we deal with unicode 
representations of
-               domain names and do not convert from or to ASCII 
representations using
-               punycode encoding. When such a conversion is needed, the 
L{idna} standard
-               library provides the C{ToUnicode()} and C{ToASCII()} functions. 
Note that
-               L{idna} itself assumes UseSTD3ASCIIRules to be false.
+       We do not perform step 4 since we deal with unicode representations of
+       domain names and do not convert from or to ASCII representations using
+       punycode encoding. When such a conversion is needed, the L{idna} 
standard
+       library provides the C{ToUnicode()} and C{ToASCII()} functions. Note 
that
+       L{idna} itself assumes UseSTD3ASCIIRules to be false.
 
-               The following steps are performed by C{prepare()}:
+       The following steps are performed by C{prepare()}:
 
-                       * Split the domain name in labels at the dots (RFC 
3490, 3.1)
-                       * Apply nameprep proper on each label (RFC 3491)
-                       * Enforce the restrictions on ASCII characters in host 
names by
-                               assuming STD3ASCIIRules to be true. (STD 3)
-                       * Rejoin the labels using the label separator U+002E 
(full stop).
+               * Split the domain name in labels at the dots (RFC 3490, 3.1)
+               * Apply nameprep proper on each label (RFC 3491)
+               * Enforce the restrictions on ASCII characters in host names by
+                       assuming STD3ASCIIRules to be true. (STD 3)
+               * Rejoin the labels using the label separator U+002E (full 
stop).
        """
 
        # Prohibited characters.
diff -r 67acb768d786 -r 552b79ec155d src/common/xmpp/tls_nb.py
--- a/src/common/xmpp/tls_nb.py Thu Nov 26 17:46:48 2009 +0200
+++ b/src/common/xmpp/tls_nb.py Thu Nov 26 18:12:52 2009 +0200
@@ -54,13 +54,17 @@
 
 
 class SSLWrapper:
-       '''
+       """
        Abstract SSLWrapper base class
-       '''
+       """
+
        class Error(IOError):
-               ''' Generic SSL Error Wrapper '''
+               """
+               Generic SSL Error Wrapper
+               """
+
                def __init__(self, sock=None, exc=None, errno=None, 
strerror=None,
-               peer=None):
+                               peer=None):
                        self.parent = IOError
 
                        errno = errno or gattr(exc, 'errno') or exc[0]
@@ -122,7 +126,7 @@
                log.debug("%s.__init__ called with %s", self.__class__, sslobj)
 
        def recv(self, data, flags=None):
-               '''
+               """
                Receive wrapper for SSL object
 
                We can return None out of this function to signal that no data 
is
@@ -130,16 +134,20 @@
                depending on which SSL lib we're using. Unfortunately returning 
''
                can indicate that the socket has been closed, so to be sure, we 
avoid
                this by returning None.
-               '''
+               """
                raise NotImplementedError
 
        def send(self, data, flags=None, now=False):
-               ''' Send wrapper for SSL object '''
+               """
+               Send wrapper for SSL object
+               """
                raise NotImplementedError
 
 
 class PyOpenSSLWrapper(SSLWrapper):
-       '''Wrapper class for PyOpenSSL's recv() and send() methods'''
+       """
+       Wrapper class for PyOpenSSL's recv() and send() methods
+       """
 
        def __init__(self, *args):
                self.parent = SSLWrapper
@@ -202,7 +210,9 @@
 
 
 class StdlibSSLWrapper(SSLWrapper):
-       '''Wrapper class for Python socket.ssl read() and write() methods'''
+       """
+       Wrapper class for Python socket.ssl read() and write() methods
+       """
 
        def __init__(self, *args):
                self.parent = SSLWrapper
@@ -230,18 +240,18 @@
 
 
 class NonBlockingTLS(PlugIn):
-       '''
-       TLS connection used to encrypts already estabilished tcp connection.
+       """
+       TLS connection used to encrypts already estabilished tcp connection
 
        Can be plugged into NonBlockingTCP and will make use of 
StdlibSSLWrapper or
        PyOpenSSLWrapper.
-       '''
+       """
 
        def __init__(self, cacerts, mycerts):
-               '''
+               """
                :param cacerts: path to pem file with certificates of known 
XMPP servers
                :param mycerts: path to pem file with certificates of user 
trusted servers
-               '''
+               """
                PlugIn.__init__(self)
                self.cacerts = cacerts
                self.mycerts = mycerts
@@ -254,10 +264,10 @@
                        "SSL_CB_HANDSHAKE_START": 0x10, 
"SSL_CB_HANDSHAKE_DONE": 0x20}
 
        def plugin(self, owner):
-               '''
-               Use to PlugIn TLS into transport and start establishing 
immediately
-               Returns True if TLS/SSL was established correctly, otherwise 
False.
-               '''
+               """
+               Use to PlugIn TLS into transport and start establishing 
immediately.
+               Returns True if TLS/SSL was established correctly, otherwise 
False
+               """
                log.info('Starting TLS estabilishing')
                try:
                        res = self._startSSL()
@@ -289,7 +299,9 @@
                        "Unknown"), pkey.type())
 
        def _startSSL(self):
-               ''' Immediatedly switch socket to TLS mode. Used internally.'''
+               """
+               Immediatedly switch socket to TLS mode. Used internally
+               """
                log.debug("_startSSL called")
 
                if USE_PYOPENSSL:
diff -r 67acb768d786 -r 552b79ec155d src/common/xmpp/transports_nb.py
--- a/src/common/xmpp/transports_nb.py  Thu Nov 26 17:46:48 2009 +0200
+++ b/src/common/xmpp/transports_nb.py  Thu Nov 26 18:12:52 2009 +0200
@@ -15,14 +15,14 @@
 ##   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ##   GNU General Public License for more details.
 
-'''
+"""
 Transports are objects responsible for connecting to XMPP server and putting
 data to wrapped sockets in in desired form (SSL, TLS, TCP, for HTTP proxy,
 for SOCKS5 proxy...)
 
 Transports are not aware of XMPP stanzas and only responsible for low-level
 connection handling.
-'''
+"""
 
 from simplexml import ustr
 from plugin import PlugIn
@@ -41,12 +41,12 @@
 log = logging.getLogger('gajim.c.x.transports_nb')
 
 def urisplit(uri):
-       '''
+       """
        Function for splitting URI string to tuple (protocol, host, port, path).
-       e.g. urisplit('http://httpcm.jabber.org:123/webclient') returns
-       ('http', 'httpcm.jabber.org', 123, '/webclient')
-       return 443 as default port if proto is https else 80
-       '''
+       e.g. urisplit('http://httpcm.jabber.org:123/webclient') returns ('http',
+       'httpcm.jabber.org', 123, '/webclient') return 443 as default port if 
proto
+       is https else 80
+       """
        splitted =  urlparse.urlsplit(uri)
        proto, host, path = splitted.scheme, splitted.hostname, splitted.path
        try:
@@ -102,17 +102,18 @@
 STATES = (DISCONNECTED, CONNECTING, PROXY_CONNECTING, CONNECTED, DISCONNECTING)
 
 class NonBlockingTransport(PlugIn):
-       '''
-       Abstract class representing a transport.
+       """
+       Abstract class representing a transport
 
        Subclasses CAN have different constructor signature but connect method 
SHOULD
        be the same.
-       '''
+       """
+
        def __init__(self, raise_event, on_disconnect, idlequeue, 
estabilish_tls,
-       certs):
-               '''
+                       certs):
+               """
                Each trasport class can have different constructor but it has 
to have at
-               least all the arguments of NonBlockingTransport constructor.
+               least all the arguments of NonBlockingTransport constructor
 
                :param raise_event: callback for monitoring of sent and 
received data
                :param on_disconnect: callback called on disconnection during 
runtime
@@ -121,7 +122,7 @@
                        TCP connection is done
                :param certs: tuple of (cacerts, mycerts) see constructor of
                        tls_nb.NonBlockingTLS for more details
-               '''
+               """
                PlugIn.__init__(self)
                self.raise_event = raise_event
                self.on_disconnect = on_disconnect
@@ -157,14 +158,14 @@
                self.disconnect(do_callback=False)
 
        def connect(self, conn_5tuple, on_connect, on_connect_failure):
-               '''
+               """
                Creates and connects transport to server and port defined in 
conn_5tuple
-               which should be item from list returned from getaddrinfo.
+               which should be item from list returned from getaddrinfo
 
                :param conn_5tuple: 5-tuple returned from getaddrinfo
                :param on_connect: callback called on successful connect to the 
server
                :param on_connect_failure: callback called on failure when 
connecting
-               '''
+               """
                self.on_connect = on_connect
                self.on_connect_failure = on_connect_failure
                self.server, self.port = conn_5tuple[4][:2]
@@ -178,14 +179,18 @@
                return self.state
 
        def _on_connect(self):
-               ''' preceeds call of on_connect callback '''
+               """
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to