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

Method _connect

Lib/imaplib.py:233–272  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

231
232
233 def _connect(self):
234 # Create unique tag for this session,
235 # and compile tagged response matcher.
236
237 self.tagpre = Int2AP(random.randint(4096, 65535))
238 self.tagre = re.compile(br'(?P<tag>'
239 + self.tagpre
240 + br'\d+) (?P<type>[A-Z]+) (?P<data>.*)', re.ASCII)
241
242 # Get server welcome message,
243 # request and store CAPABILITY response.
244
245 if __debug__:
246 self._cmd_log_len = 10
247 self._cmd_log_idx = 0
248 self._cmd_log = {} # Last '_cmd_log_len' interactions
249 if self.debug >= 1:
250 self._mesg('imaplib version %s' % __version__)
251 self._mesg('new IMAP4 connection, tag=%s' % self.tagpre)
252
253 self.welcome = self._get_response()
254 if 'PREAUTH' in self.untagged_responses:
255 self.state = 'AUTH'
256 elif 'OK' in self.untagged_responses:
257 self.state = 'NONAUTH'
258 else:
259 raise self.error(self.welcome)
260
261 self._get_capabilities()
262 if __debug__:
263 if self.debug >= 3:
264 self._mesg('CAPABILITIES: %r' % (self.capabilities,))
265
266 for version in AllowedVersions:
267 if not version in self.capabilities:
268 continue
269 self.PROTOCOL_VERSION = version
270 return
271
272 raise self.error('server not IMAP4 compliant')
273
274
275 def __getattr__(self, attr):

Callers 1

__init__Method · 0.95

Calls 7

_mesgMethod · 0.95
_get_responseMethod · 0.95
_get_capabilitiesMethod · 0.95
Int2APFunction · 0.85
randintMethod · 0.80
compileMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected