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
7c4093ca
Kaydet (Commit)
7c4093ca
authored
Eyl 20, 2014
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge: #21091: make is_attachment a method.
üst
1de0ac05
8a97896a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
10 deletions
+17
-10
email.contentmanager.rst
Doc/library/email.contentmanager.rst
+6
-2
message.py
Lib/email/message.py
+3
-3
test_message.py
Lib/test/test_email/test_message.py
+5
-5
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/email.contentmanager.rst
Dosyayı görüntüle @
7c4093ca
...
@@ -70,11 +70,15 @@ this module.
...
@@ -70,11 +70,15 @@ this module.
the following methods:
the following methods:
..
attribute
:: is_attachment
..
method
:: is_attachment
Set to
``True`` if there is a :mailheader:`Content-Disposition` header
Return
``True`` if there is a :mailheader:`Content-Disposition` header
and its (case insensitive) value is ``attachment``, ``False`` otherwise.
and its (case insensitive) value is ``attachment``, ``False`` otherwise.
.. versionchanged:: 3.4.2
is_attachment is now a method instead of a property, for consistency
with :meth:`~email.message.Message.is_multipart`.
.. method:: get_body(preferencelist=('related', 'html', 'plain'))
.. method:: get_body(preferencelist=('related', 'html', 'plain'))
...
...
Lib/email/message.py
Dosyayı görüntüle @
7c4093ca
...
@@ -9,6 +9,7 @@ __all__ = ['Message']
...
@@ -9,6 +9,7 @@ __all__ = ['Message']
import
re
import
re
import
uu
import
uu
import
quopri
import
quopri
import
warnings
from
io
import
BytesIO
,
StringIO
from
io
import
BytesIO
,
StringIO
# Intrapackage imports
# Intrapackage imports
...
@@ -938,13 +939,12 @@ class MIMEPart(Message):
...
@@ -938,13 +939,12 @@ class MIMEPart(Message):
policy
=
default
policy
=
default
Message
.
__init__
(
self
,
policy
)
Message
.
__init__
(
self
,
policy
)
@property
def
is_attachment
(
self
):
def
is_attachment
(
self
):
c_d
=
self
.
get
(
'content-disposition'
)
c_d
=
self
.
get
(
'content-disposition'
)
return
False
if
c_d
is
None
else
c_d
.
content_disposition
==
'attachment'
return
False
if
c_d
is
None
else
c_d
.
content_disposition
==
'attachment'
def
_find_body
(
self
,
part
,
preferencelist
):
def
_find_body
(
self
,
part
,
preferencelist
):
if
part
.
is_attachment
:
if
part
.
is_attachment
()
:
return
return
maintype
,
subtype
=
part
.
get_content_type
()
.
split
(
'/'
)
maintype
,
subtype
=
part
.
get_content_type
()
.
split
(
'/'
)
if
maintype
==
'text'
:
if
maintype
==
'text'
:
...
@@ -1037,7 +1037,7 @@ class MIMEPart(Message):
...
@@ -1037,7 +1037,7 @@ class MIMEPart(Message):
for
part
in
parts
:
for
part
in
parts
:
maintype
,
subtype
=
part
.
get_content_type
()
.
split
(
'/'
)
maintype
,
subtype
=
part
.
get_content_type
()
.
split
(
'/'
)
if
((
maintype
,
subtype
)
in
self
.
_body_types
and
if
((
maintype
,
subtype
)
in
self
.
_body_types
and
not
part
.
is_attachment
and
subtype
not
in
seen
):
not
part
.
is_attachment
()
and
subtype
not
in
seen
):
seen
.
append
(
subtype
)
seen
.
append
(
subtype
)
continue
continue
yield
part
yield
part
...
...
Lib/test/test_email/test_message.py
Dosyayı görüntüle @
7c4093ca
...
@@ -722,15 +722,15 @@ class TestEmailMessageBase:
...
@@ -722,15 +722,15 @@ class TestEmailMessageBase:
def
test_is_attachment
(
self
):
def
test_is_attachment
(
self
):
m
=
self
.
_make_message
()
m
=
self
.
_make_message
()
self
.
assertFalse
(
m
.
is_attachment
)
self
.
assertFalse
(
m
.
is_attachment
()
)
m
[
'Content-Disposition'
]
=
'inline'
m
[
'Content-Disposition'
]
=
'inline'
self
.
assertFalse
(
m
.
is_attachment
)
self
.
assertFalse
(
m
.
is_attachment
()
)
m
.
replace_header
(
'Content-Disposition'
,
'attachment'
)
m
.
replace_header
(
'Content-Disposition'
,
'attachment'
)
self
.
assertTrue
(
m
.
is_attachment
)
self
.
assertTrue
(
m
.
is_attachment
()
)
m
.
replace_header
(
'Content-Disposition'
,
'AtTachMent'
)
m
.
replace_header
(
'Content-Disposition'
,
'AtTachMent'
)
self
.
assertTrue
(
m
.
is_attachment
)
self
.
assertTrue
(
m
.
is_attachment
()
)
m
.
set_param
(
'filename'
,
'abc.png'
,
'Content-Disposition'
)
m
.
set_param
(
'filename'
,
'abc.png'
,
'Content-Disposition'
)
self
.
assertTrue
(
m
.
is_attachment
)
self
.
assertTrue
(
m
.
is_attachment
()
)
class
TestEmailMessage
(
TestEmailMessageBase
,
TestEmailBase
):
class
TestEmailMessage
(
TestEmailMessageBase
,
TestEmailBase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
7c4093ca
...
@@ -137,6 +137,9 @@ Core and Builtins
...
@@ -137,6 +137,9 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
21091
:
Fix
API
bug
:
email
.
message
.
EmailMessage
.
is_attachment
is
now
a
method
.
-
Issue
#
21079
:
Fix
email
.
message
.
EmailMessage
.
is_attachment
to
return
the
-
Issue
#
21079
:
Fix
email
.
message
.
EmailMessage
.
is_attachment
to
return
the
correct
result
when
the
header
has
parameters
as
well
as
a
value
.
correct
result
when
the
header
has
parameters
as
well
as
a
value
.
...
...
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