--- /usr/local/lib/python2.4/imaplib.py Sun May 27 13:20:55 2007 +++ /nile/u/ntai/sand/pimt/imaplib.py Tue Jun 12 02:12:09 2007 @@ -145,7 +145,7 @@ mustquote = re.compile(r"[^\w!#$%&'*+,.:;<=>?^`|~-]") - def __init__(self, host = '', port = IMAP4_PORT): + def __init__(self, host = '', port = IMAP4_PORT, response_format = 1): self.debug = Debug self.state = 'LOGOUT' self.literal = None # A literal argument to a command @@ -154,6 +154,7 @@ self.continuation_response = '' # Last continuation response self.is_readonly = None # READ-ONLY desired state self.tagnum = 0 + self.response_format = response_format # Open socket to server. @@ -190,7 +191,10 @@ self._simple_command(cap) if not cap in self.untagged_responses: raise self.error('no CAPABILITY response from server') - self.capabilities = tuple(self.untagged_responses[cap][-1].upper().split()) + if (self.response_format == 1): + self.capabilities = tuple(self.untagged_responses[cap][-1].upper().split()) + else: + self.capabilities = tuple(self.untagged_responses[cap][0][-1].upper().split()) if __debug__: if self.debug >= 3: @@ -908,7 +912,11 @@ if dat is None: dat = '' # Null untagged response if dat2: dat = dat + ' ' + dat2 - # Is there a literal to come? + if self.response_format != 1: + # Is there a literal to come? + literals = [] + reply = '' + pass while self._match(Literal, dat): @@ -920,15 +928,30 @@ self._mesg('read literal size %s' % size) data = self.read(size) - # Store response with literal as tuple - - self._append_untagged(typ, (dat, data)) + if self.response_format == 1: + # Store response with literal as tuple + self._append_untagged(typ, (dat, data)) + else: + reply = reply + dat + literals.append(data) + pass # Read trailer - possibly containing another literal dat = self._get_line() + pass - self._append_untagged(typ, dat) + if self.response_format == 1: + self._append_untagged(typ, dat) + else: + reply = reply + dat + if len(literals) > 0: + self._append_untagged(typ, [reply, literals]) + else: + self._append_untagged(typ, [reply]) + pass + pass + pass # Bracketed response information?