Index: Lib/imaplib.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/imaplib.py,v retrieving revision 1.6 retrieving revision 1.8 diff -c -r1.6 -r1.8 *** imaplib.py 1998/05/18 14:39:42 1.6 --- imaplib.py 1998/05/29 13:34:03 1.8 *************** *** 12,18 **** Time2Internaldate """ ! import re, socket, string, time, whrandom # Globals --- 12,18 ---- Time2Internaldate """ ! import re, socket, string, time, random # Globals *************** *** 77,85 **** port - port number (default: standard IMAP4 port). All IMAP4rev1 commands are supported by methods of the same ! name (in lower-case). Each command returns a tuple: (type, [data, ...]) ! where 'type' is usually 'OK' or 'NO', and 'data' is either the ! text from the tagged response, or untagged results from command. Errors raise the exception class .error(""). IMAP4 server errors raise .abort(""), --- 77,92 ---- port - port number (default: standard IMAP4 port). All IMAP4rev1 commands are supported by methods of the same ! name (in lower-case). ! ! All arguments to commands are converted to strings, except for ! the last argument to APPEND which is passed as an IMAP4 ! literal. If necessary (the string isn't enclosed with either ! parentheses or double quotes) each converted string is quoted. ! ! Each command returns a tuple: (type, [data, ...]) where 'type' ! is usually 'OK' or 'NO', and 'data' is either the text from the ! tagged response, or untagged results from command. Errors raise the exception class .error(""). IMAP4 server errors raise .abort(""), *************** *** 95,100 **** --- 102,108 ---- self.port = port self.debug = Debug self.state = 'LOGOUT' + self.literal = None # A literal argument to a command self.tagged_commands = {} # Tagged commands awaiting response self.untagged_responses = {} # {typ: [data, ...], ...} self.continuation_response = '' # Last continuation response *************** *** 109,115 **** # Create unique tag for this session, # and compile tagged response matcher. ! self.tagpre = Int2AP(whrandom.random()*32000) self.tagre = re.compile(r'(?P' + self.tagpre + r'\d+) (?P[A-Z]+) (?P.*)') --- 117,123 ---- # Create unique tag for this session, # and compile tagged response matcher. ! self.tagpre = Int2AP(random.randint(0, 31999)) self.tagre = re.compile(r'(?P' + self.tagpre + r'\d+) (?P[A-Z]+) (?P.*)') *************** *** 172,178 **** date_time = Time2Internaldate(date_time) else: date_time = None ! return self._simple_command(name, mailbox, flags, date_time, message) def authenticate(self, func): --- 180,187 ---- date_time = Time2Internaldate(date_time) else: date_time = None ! self.literal = message ! return self._simple_command(name, mailbox, flags, date_time) def authenticate(self, func): *************** *** 310,319 **** return self._untagged_response(typ, name) ! def recent(self): ! """Prompt server for an update. ! Flush all untagged responses. (typ, [data]) = .recent() --- 319,336 ---- return self._untagged_response(typ, name) ! def noop(self): ! """Send NOOP command. ! (typ, data) = .noop() ! """ ! return self._simple_command('NOOP') ! ! ! def recent(self): ! """Return most recent 'RECENT' response if it exists, ! else prompt server for an update using the 'NOOP' command, ! and flush all untagged responses. (typ, [data]) = .recent() *************** *** 468,482 **** print '\tuntagged_responses[%s] += %.20s..' % (typ, `dat`) ! def _command(self, name, dat1=None, dat2=None, dat3=None, literal=None): if self.state not in Commands[name]: raise self.error( 'command %s illegal in state %s' % (name, self.state)) tag = self._new_tag() data = '%s %s' % (tag, name) ! for d in (dat1, dat2, dat3): if d is None: continue if type(d) is type(''): l = len(string.split(d)) --- 485,500 ---- print '\tuntagged_responses[%s] += %.20s..' % (typ, `dat`) ! def _command(self, name, *args): if self.state not in Commands[name]: + self.literal = None raise self.error( 'command %s illegal in state %s' % (name, self.state)) tag = self._new_tag() data = '%s %s' % (tag, name) ! for d in args: if d is None: continue if type(d) is type(''): l = len(string.split(d)) *************** *** 486,492 **** --- 504,513 ---- data = '%s "%s"' % (data, d) else: data = '%s %s' % (data, d) + + literal = self.literal if literal is not None: + self.literal = None data = '%s {%s}' % (data, len(literal)) try: