Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
25cee19b
Kaydet (Commit)
25cee19b
authored
Kas 23, 2012
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #4473: Add a POP3.capa() method to query the capabilities advertised by the POP3 server.
Patch by Lorenzo Catucci.
üst
d89824b0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
0 deletions
+57
-0
poplib.rst
Doc/library/poplib.rst
+8
-0
poplib.py
Lib/poplib.py
+30
-0
test_poplib.py
Lib/test/test_poplib.py
+16
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/poplib.rst
Dosyayı görüntüle @
25cee19b
...
...
@@ -97,6 +97,14 @@ An :class:`POP3` instance has the following methods:
Returns the greeting string sent by the POP3 server.
.. method:: POP3.capa()
Query the server's capabilities as specified in :rfc:`2449`.
Returns a dictionary in the form ``{'name': ['param'...]}``.
.. versionadded:: 3.4
.. method:: POP3.user(username)
Send user command, response should indicate that a password is required.
...
...
Lib/poplib.py
Dosyayı görüntüle @
25cee19b
...
...
@@ -55,6 +55,7 @@ class POP3:
APOP name digest apop(name, digest)
TOP msg n top(msg, n)
UIDL [msg] uidl(msg = None)
CAPA capa()
Raises one exception: 'error_proto'.
...
...
@@ -322,6 +323,35 @@ class POP3:
return
self
.
_shortcmd
(
'UIDL
%
s'
%
which
)
return
self
.
_longcmd
(
'UIDL'
)
def
capa
(
self
):
"""Return server capabilities (RFC 2449) as a dictionary
>>> c=poplib.POP3('localhost')
>>> c.capa()
{'IMPLEMENTATION': ['Cyrus', 'POP3', 'server', 'v2.2.12'],
'TOP': [], 'LOGIN-DELAY': ['0'], 'AUTH-RESP-CODE': [],
'EXPIRE': ['NEVER'], 'USER': [], 'STLS': [], 'PIPELINING': [],
'UIDL': [], 'RESP-CODES': []}
>>>
Really, according to RFC 2449, the cyrus folks should avoid
having the implementation splitted into multiple arguments...
"""
def
_parsecap
(
line
):
lst
=
line
.
decode
(
'ascii'
)
.
split
()
return
lst
[
0
],
lst
[
1
:]
caps
=
{}
try
:
resp
=
self
.
_longcmd
(
'CAPA'
)
rawcaps
=
resp
[
1
]
for
capline
in
rawcaps
:
capnm
,
capargs
=
_parsecap
(
capline
)
caps
[
capnm
]
=
capargs
except
error_proto
as
_err
:
raise
error_proto
(
'-ERR CAPA not supported by server'
)
return
caps
try
:
import
ssl
except
ImportError
:
...
...
Lib/test/test_poplib.py
Dosyayı görüntüle @
25cee19b
...
...
@@ -33,6 +33,8 @@ line3\r\n\
class
DummyPOP3Handler
(
asynchat
.
async_chat
):
CAPAS
=
{
'UIDL'
:
[],
'IMPLEMENTATION'
:
[
'python-testlib-pop-server'
]}
def
__init__
(
self
,
conn
):
asynchat
.
async_chat
.
__init__
(
self
,
conn
)
self
.
set_terminator
(
b
"
\r\n
"
)
...
...
@@ -112,6 +114,16 @@ class DummyPOP3Handler(asynchat.async_chat):
self
.
push
(
'+OK closing.'
)
self
.
close_when_done
()
def
cmd_capa
(
self
,
arg
):
self
.
push
(
'+OK Capability list follows'
)
if
self
.
CAPAS
:
for
cap
,
params
in
self
.
CAPAS
.
items
():
_ln
=
[
cap
]
if
params
:
_ln
.
extend
(
params
)
self
.
push
(
' '
.
join
(
_ln
))
self
.
push
(
'.'
)
class
DummyPOP3Server
(
asyncore
.
dispatcher
,
threading
.
Thread
):
...
...
@@ -232,6 +244,10 @@ class TestPOP3Class(TestCase):
self
.
client
.
uidl
()
self
.
client
.
uidl
(
'foo'
)
def
test_capa
(
self
):
capa
=
self
.
client
.
capa
()
self
.
assertTrue
(
'IMPLEMENTATION'
in
capa
.
keys
())
def
test_quit
(
self
):
resp
=
self
.
client
.
quit
()
self
.
assertTrue
(
resp
)
...
...
Misc/NEWS
Dosyayı görüntüle @
25cee19b
...
...
@@ -138,6 +138,9 @@ Core and Builtins
Library
-------
- Issue #4473: Add a POP3.capa() method to query the capabilities advertised
by the POP3 server. Patch by Lorenzo Catucci.
- Issue #4473: Ensure the socket is shutdown cleanly in POP3.close().
Patch by Lorenzo Catucci.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment