MCPcopy Index your code
hub / github.com/RustPython/RustPython / _get_response

Method _get_response

Lib/imaplib.py:1195–1287  ·  view source on GitHub ↗
(self, start_timeout=False)

Source from the content-addressed store, hash-verified

1193
1194
1195 def _get_response(self, start_timeout=False):
1196
1197 # Read response and store.
1198 #
1199 # Returns None for continuation responses,
1200 # otherwise first response line received.
1201 #
1202 # If start_timeout is given, temporarily uses it as a socket
1203 # timeout while waiting for the start of a response, raising
1204 # _responsetimeout if one doesn't arrive. (Used by Idler.)
1205
1206 if start_timeout is not False and self.sock:
1207 assert start_timeout is None or start_timeout > 0
1208 saved_timeout = self.sock.gettimeout()
1209 self.sock.settimeout(start_timeout)
1210 try:
1211 resp = self._get_line()
1212 except TimeoutError as err:
1213 raise self._responsetimeout from err
1214 finally:
1215 self.sock.settimeout(saved_timeout)
1216 else:
1217 resp = self._get_line()
1218
1219 # Command completion response?
1220
1221 if self._match(self.tagre, resp):
1222 tag = self.mo.group('tag')
1223 if not tag in self.tagged_commands:
1224 raise self.abort('unexpected tagged response: %r' % resp)
1225
1226 typ = self.mo.group('type')
1227 typ = str(typ, self._encoding)
1228 dat = self.mo.group('data')
1229 self.tagged_commands[tag] = (typ, [dat])
1230 else:
1231 dat2 = None
1232
1233 # '*' (untagged) responses?
1234
1235 if not self._match(Untagged_response, resp):
1236 if self._match(self.Untagged_status, resp):
1237 dat2 = self.mo.group('data2')
1238
1239 if self.mo is None:
1240 # Only other possibility is '+' (continuation) response...
1241
1242 if self._match(Continuation, resp):
1243 self.continuation_response = self.mo.group('data')
1244 return None # NB: indicates continuation
1245
1246 raise self.abort("unexpected response: %r" % resp)
1247
1248 typ = self.mo.group('type')
1249 typ = str(typ, self._encoding)
1250 dat = self.mo.group('data')
1251 if dat is None: dat = b'' # Null untagged response
1252 if dat2: dat = dat + b' ' + dat2

Callers 5

_connectMethod · 0.95
_commandMethod · 0.95
_get_tagged_responseMethod · 0.95
__enter__Method · 0.80
_popMethod · 0.80

Calls 10

_get_lineMethod · 0.95
_matchMethod · 0.95
_mesgMethod · 0.95
readMethod · 0.95
_append_untaggedMethod · 0.95
strFunction · 0.85
gettimeoutMethod · 0.45
settimeoutMethod · 0.45
groupMethod · 0.45
abortMethod · 0.45

Tested by

no test coverage detected