Ignore:
Timestamp:
Mar 19, 2014, 11:11:30 AM (11 years ago)
Author:
dmik
Message:

python: Update vendor to 2.7.6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/vendor/current/Lib/imaplib.py

    r2 r388  
    2323__version__ = "2.58"
    2424
    25 import binascii, random, re, socket, subprocess, sys, time
     25import binascii, errno, random, re, socket, subprocess, sys, time
    2626
    2727__all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple",
     
    249249        """Close I/O established in "open"."""
    250250        self.file.close()
    251         self.sock.close()
     251        try:
     252            self.sock.shutdown(socket.SHUT_RDWR)
     253        except socket.error as e:
     254            # The server might already have closed the connection
     255            if e.errno != errno.ENOTCONN:
     256                raise
     257        finally:
     258            self.sock.close()
    252259
    253260
     
    752759        name = 'UID'
    753760        typ, dat = self._simple_command(name, command, *args)
    754         if command in ('SEARCH', 'SORT'):
     761        if command in ('SEARCH', 'SORT', 'THREAD'):
    755762            name = command
    756763        else:
     
    884891
    885892    def _command_complete(self, name, tag):
    886         self._check_bye()
     893        # BYE is expected after LOGOUT
     894        if name != 'LOGOUT':
     895            self._check_bye()
    887896        try:
    888897            typ, data = self._get_tagged_response(tag)
     
    891900        except self.error, val:
    892901            raise self.error('command: %s => %s' % (name, val))
    893         self._check_bye()
     902        if name != 'LOGOUT':
     903            self._check_bye()
    894904        if typ == 'BAD':
    895905            raise self.error('%s command error: %s %s' % (name, typ, data))
     
    11491159            self.sock = socket.create_connection((host, port))
    11501160            self.sslobj = ssl.wrap_socket(self.sock, self.keyfile, self.certfile)
     1161            self.file = self.sslobj.makefile('rb')
    11511162
    11521163
    11531164        def read(self, size):
    11541165            """Read 'size' bytes from remote."""
    1155             # sslobj.read() sometimes returns < size bytes
    1156             chunks = []
    1157             read = 0
    1158             while read < size:
    1159                 data = self.sslobj.read(min(size-read, 16384))
    1160                 read += len(data)
    1161                 chunks.append(data)
    1162 
    1163             return ''.join(chunks)
     1166            return self.file.read(size)
    11641167
    11651168
    11661169        def readline(self):
    11671170            """Read line from remote."""
    1168             line = []
    1169             while 1:
    1170                 char = self.sslobj.read(1)
    1171                 line.append(char)
    1172                 if char in ("\n", ""): return ''.join(line)
     1171            return self.file.readline()
    11731172
    11741173
     
    11861185        def shutdown(self):
    11871186            """Close I/O established in "open"."""
     1187            self.file.close()
    11881188            self.sock.close()
    11891189
     
    12131213    Instantiate with: IMAP4_stream(command)
    12141214
    1215             where "command" is a string that can be passed to Subprocess.Popen()
     1215            where "command" is a string that can be passed to subprocess.Popen()
    12161216
    12171217    for more documentation see the docstring of the parent class IMAP4.
     
    13121312
    13131313def Internaldate2tuple(resp):
    1314     """Convert IMAP4 INTERNALDATE to UT.
    1315 
    1316     Returns Python time module tuple.
     1314    """Parse an IMAP4 INTERNALDATE string.
     1315
     1316    Return corresponding local time.  The return value is a
     1317    time.struct_time instance or None if the string has wrong format.
    13171318    """
    13181319
     
    13811382def Time2Internaldate(date_time):
    13821383
    1383     """Convert 'date_time' to IMAP4 INTERNALDATE representation.
    1384 
    1385     Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'
     1384    """Convert date_time to IMAP4 INTERNALDATE representation.
     1385
     1386    Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'.  The
     1387    date_time argument can be a number (int or float) representing
     1388    seconds since epoch (as returned by time.time()), a 9-tuple
     1389    representing local time (as returned by time.localtime()), or a
     1390    double-quoted string.  In the last case, it is assumed to already
     1391    be in the correct format.
    13861392    """
    13871393
Note: See TracChangeset for help on using the changeset viewer.