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
b744f3a4
Kaydet (Commit)
b744f3a4
authored
May 16, 2015
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#21083: add get_content_disposition method to email.message.
Patch by Abhilash Raj.
üst
b9cec6a3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
0 deletions
+41
-0
email.message.rst
Doc/library/email.message.rst
+9
-0
3.5.rst
Doc/whatsnew/3.5.rst
+8
-0
message.py
Lib/email/message.py
+12
-0
test_email.py
Lib/test/test_email/test_email.py
+11
-0
ACKS
Misc/ACKS
+1
-0
No files found.
Doc/library/email.message.rst
Dosyayı görüntüle @
b744f3a4
...
@@ -578,6 +578,15 @@ Here are the methods of the :class:`Message` class:
...
@@ -578,6 +578,15 @@ Here are the methods of the :class:`Message` class:
will be *failobj*.
will be *failobj*.
.. method:: get_content_disposition()
Return the lowercased value (without parameters) of the message's
:mailheader:`Content-Disposition` header if it has one, or ``None``. The
possible values for this method are *inline*, *attachment* or ``None``
if the message follows :rfc:`2183`.
.. versionadded:: 3.5
.. method:: walk()
.. method:: walk()
The :meth:`walk` method is an all-purpose generator which can be used to
The :meth:`walk` method is an all-purpose generator which can be used to
...
...
Doc/whatsnew/3.5.rst
Dosyayı görüntüle @
b744f3a4
...
@@ -348,6 +348,14 @@ doctest
...
@@ -348,6 +348,14 @@ doctest
*module* contains no docstrings instead of raising :exc:`ValueError`.
*module* contains no docstrings instead of raising :exc:`ValueError`.
(Contributed by Glenn Jones in :issue:`15916`.)
(Contributed by Glenn Jones in :issue:`15916`.)
email
-----
* A new method :meth:`~email.message.Message.get_content_disposition` provides
easy access to a canonical value for the :mailheader:`Content-Disposition`
header (``None`` if there is no such header). (Contributed by Abhilash Raj
in :issue:`21083`.)
glob
glob
----
----
...
...
Lib/email/message.py
Dosyayı görüntüle @
b744f3a4
...
@@ -927,6 +927,18 @@ class Message:
...
@@ -927,6 +927,18 @@ class Message:
"""
"""
return
[
part
.
get_content_charset
(
failobj
)
for
part
in
self
.
walk
()]
return
[
part
.
get_content_charset
(
failobj
)
for
part
in
self
.
walk
()]
def
get_content_disposition
(
self
):
"""Return the message's content-disposition if it exists, or None.
The return values can be either 'inline', 'attachment' or None
according to the rfc2183.
"""
value
=
self
.
get
(
'content-disposition'
)
if
value
is
None
:
return
None
c_d
=
_splitparam
(
value
)[
0
]
.
lower
()
return
c_d
# I.e. def walk(self): ...
# I.e. def walk(self): ...
from
email.iterators
import
walk
from
email.iterators
import
walk
...
...
Lib/test/test_email/test_email.py
Dosyayı görüntüle @
b744f3a4
...
@@ -586,6 +586,17 @@ class TestMessageAPI(TestEmailBase):
...
@@ -586,6 +586,17 @@ class TestMessageAPI(TestEmailBase):
eq
(
msg
.
values
(),
[
'One Hundred'
,
'Twenty'
,
'Three'
,
'Eleven'
])
eq
(
msg
.
values
(),
[
'One Hundred'
,
'Twenty'
,
'Three'
,
'Eleven'
])
self
.
assertRaises
(
KeyError
,
msg
.
replace_header
,
'Fourth'
,
'Missing'
)
self
.
assertRaises
(
KeyError
,
msg
.
replace_header
,
'Fourth'
,
'Missing'
)
def
test_get_content_disposition
(
self
):
msg
=
Message
()
self
.
assertIsNone
(
msg
.
get_content_disposition
())
msg
.
add_header
(
'Content-Disposition'
,
'attachment'
,
filename
=
'random.avi'
)
self
.
assertEqual
(
msg
.
get_content_disposition
(),
'attachment'
)
msg
.
replace_header
(
'Content-Disposition'
,
'inline'
)
self
.
assertEqual
(
msg
.
get_content_disposition
(),
'inline'
)
msg
.
replace_header
(
'Content-Disposition'
,
'InlinE'
)
self
.
assertEqual
(
msg
.
get_content_disposition
(),
'inline'
)
# test_defect_handling:test_invalid_chars_in_base64_payload
# test_defect_handling:test_invalid_chars_in_base64_payload
def
test_broken_base64_payload
(
self
):
def
test_broken_base64_payload
(
self
):
x
=
'AwDp0P7//y6LwKEAcPa/6Q=9'
x
=
'AwDp0P7//y6LwKEAcPa/6Q=9'
...
...
Misc/ACKS
Dosyayı görüntüle @
b744f3a4
...
@@ -1134,6 +1134,7 @@ Thomas Rachel
...
@@ -1134,6 +1134,7 @@ Thomas Rachel
Ram Rachum
Ram Rachum
Jérôme Radix
Jérôme Radix
Burton Radons
Burton Radons
Abhilash Raj
Shorya Raj
Shorya Raj
Jeff Ramnani
Jeff Ramnani
Brodie Rao
Brodie Rao
...
...
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