Lines Matching refs:self
98 def __init__(self, host, port=POP3_PORT,
100 self.host = host
101 self.port = port
102 self._tls_established = False
103 sys.audit("poplib.connect", self, host, port)
104 self.sock = self._create_socket(timeout)
105 self.file = self.sock.makefile('rb')
106 self._debugging = 0
107 self.welcome = self._getresp()
109 def _create_socket(self, timeout):
112 return socket.create_connection((self.host, self.port), timeout)
114 def _putline(self, line):
115 if self._debugging > 1: print('*put*', repr(line))
116 sys.audit("poplib.putline", self, line)
117 self.sock.sendall(line + CRLF)
122 def _putcmd(self, line):
123 if self._debugging: print('*cmd*', repr(line))
124 line = bytes(line, self.encoding)
125 self._putline(line)
132 def _getline(self):
133 line = self.file.readline(_MAXLINE + 1)
137 if self._debugging > 1: print('*get*', repr(line))
153 def _getresp(self):
154 resp, o = self._getline()
155 if self._debugging > 1: print('*resp*', repr(resp))
163 def _getlongresp(self):
164 resp = self._getresp()
166 line, o = self._getline()
173 line, o = self._getline()
179 def _shortcmd(self, line):
180 self._putcmd(line)
181 return self._getresp()
186 def _longcmd(self, line):
187 self._putcmd(line)
188 return self._getlongresp()
193 def getwelcome(self):
194 return self.welcome
197 def set_debuglevel(self, level):
198 self._debugging = level
203 def user(self, user):
208 return self._shortcmd('USER %s' % user)
211 def pass_(self, pswd):
218 return self._shortcmd('PASS %s' % pswd)
221 def stat(self):
226 retval = self._shortcmd('STAT')
228 if self._debugging: print('*stat*', repr(rets))
234 def list(self, which=None):
244 return self._shortcmd('LIST %s' % which)
245 return self._longcmd('LIST')
248 def retr(self, which):
253 return self._longcmd('RETR %s' % which)
256 def dele(self, which):
261 return self._shortcmd('DELE %s' % which)
264 def noop(self):
269 return self._shortcmd('NOOP')
272 def rset(self):
274 return self._shortcmd('RSET')
277 def quit(self):
279 resp = self._shortcmd('QUIT')
280 self.close()
283 def close(self):
286 file = self.file
287 self.file = None
291 sock = self.sock
292 self.sock = None
311 def rpop(self, user):
313 return self._shortcmd('RPOP %s' % user)
318 def apop(self, user, password):
329 secret = bytes(password, self.encoding)
330 m = self.timestamp.match(self.welcome)
336 return self._shortcmd('APOP %s %s' % (user, digest))
339 def top(self, which, howmuch):
345 return self._longcmd('TOP %s %s' % (which, howmuch))
348 def uidl(self, which=None):
356 return self._shortcmd('UIDL %s' % which)
357 return self._longcmd('UIDL')
360 def utf8(self):
363 return self._shortcmd('UTF8')
366 def capa(self):
385 resp = self._longcmd('CAPA')
395 def stls(self, context=None):
402 if self._tls_established:
404 caps = self.capa()
409 resp = self._shortcmd('STLS')
410 self.sock = context.wrap_socket(self.sock,
411 server_hostname=self.host)
412 self.file = self.sock.makefile('rb')
413 self._tls_established = True
434 def __init__(self, host, port=POP3_SSL_PORT, keyfile=None, certfile=None,
446 self.keyfile = keyfile
447 self.certfile = certfile
451 self.context = context
452 POP3.__init__(self, host, port, timeout)
454 def _create_socket(self, timeout):
455 sock = POP3._create_socket(self, timeout)
456 sock = self.context.wrap_socket(sock,
457 server_hostname=self.host)
460 def stls(self, keyfile=None, certfile=None, context=None):