Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
12dc230c
Commit
12dc230c
authored
Mar 11, 2003
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
body_line_iterator(): Accept optional decode argument, pass through to
Message.get_payload().
parent
52b39f5b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
Lib/email/_compat21.py
Lib/email/_compat21.py
+6
-3
Lib/email/_compat22.py
Lib/email/_compat22.py
+6
-3
No files found.
Lib/email/_compat21.py
View file @
12dc230c
...
...
@@ -37,11 +37,14 @@ def _isstring(obj):
# These two functions are imported into the Iterators.py interface module.
# The Python 2.2 version uses generators for efficiency.
def
body_line_iterator
(
msg
):
"""Iterate over the parts, returning string payloads line-by-line."""
def
body_line_iterator
(
msg
,
decode
=
False
):
"""Iterate over the parts, returning string payloads line-by-line.
Optional decode (default False) is passed through to .get_payload().
"""
lines
=
[]
for
subpart
in
msg
.
walk
():
payload
=
subpart
.
get_payload
()
payload
=
subpart
.
get_payload
(
decode
=
decode
)
if
_isstring
(
payload
):
for
line
in
StringIO
(
payload
).
readlines
():
lines
.
append
(
line
)
...
...
Lib/email/_compat22.py
View file @
12dc230c
...
...
@@ -38,10 +38,13 @@ def _isstring(obj):
# These two functions are imported into the Iterators.py interface module.
# The Python 2.2 version uses generators for efficiency.
def
body_line_iterator
(
msg
):
"""Iterate over the parts, returning string payloads line-by-line."""
def
body_line_iterator
(
msg
,
decode
=
False
):
"""Iterate over the parts, returning string payloads line-by-line.
Optional decode (default False) is passed through to .get_payload().
"""
for
subpart
in
msg
.
walk
():
payload
=
subpart
.
get_payload
()
payload
=
subpart
.
get_payload
(
decode
=
decode
)
if
_isstring
(
payload
):
for
line
in
StringIO
(
payload
):
yield
line
...
...
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