MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _connect

Method _connect

tools/python-3.11.9-amd64/Lib/imaplib.py:227–266  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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