replace imaplib internal _get_untagged_response with public functions

We were using the internal imaplib2 _get_untagged_response() functions a
few times. Replace 3 of these calls with 2 calls to the public function
response() rather than fudging with internals that could change anytime.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
Sebastian Spaeth 2012-01-07 01:28:20 +01:00
parent 1b85e35256
commit ec63b4fe6b

View File

@ -68,9 +68,10 @@ class IMAPFolder(BaseFolder):
def getuidvalidity(self): def getuidvalidity(self):
imapobj = self.imapserver.acquireconnection() imapobj = self.imapserver.acquireconnection()
try: try:
# Primes untagged_responses # SELECT receives UIDVALIDITY response
self.selectro(imapobj) self.selectro(imapobj)
return long(imapobj._get_untagged_response('UIDVALIDITY', True)[0]) typ, uidval = imapobj.response('UIDVALIDITY')
return long(uidval[0])
finally: finally:
self.imapserver.releaseconnection(imapobj) self.imapserver.releaseconnection(imapobj)
@ -563,14 +564,15 @@ class IMAPFolder(BaseFolder):
# get the new UID. Test for APPENDUID response even if the # get the new UID. Test for APPENDUID response even if the
# server claims to not support it, as e.g. Gmail does :-( # server claims to not support it, as e.g. Gmail does :-(
if use_uidplus or imapobj._get_untagged_response('APPENDUID', True): if use_uidplus or imapobj._get_untagged_response('APPENDUID', True):
# get the new UID from the APPENDUID response, it could look like # get new UID from the APPENDUID response, it could look
# OK [APPENDUID 38505 3955] APPEND completed # like OK [APPENDUID 38505 3955] APPEND completed with
# with 38505 bein folder UIDvalidity and 3955 the new UID # 38505 bein folder UIDvalidity and 3955 the new UID
if not imapobj._get_untagged_response('APPENDUID', True): typ, resp = imapobj.response('APPENDUID')
if resp == [None]:
self.ui.warn("Server supports UIDPLUS but got no APPENDUID " self.ui.warn("Server supports UIDPLUS but got no APPENDUID "
"appending a message.") "appending a message. %s" % imapobj._get_untagged_response('APPENDUID', True))
return 0 return 0
uid = long(imapobj._get_untagged_response('APPENDUID')[-1].split(' ')[1]) uid = long(resp[-1].split(' ')[1])
else: else:
# we don't support UIDPLUS # we don't support UIDPLUS