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
94f162f5
Commit
94f162f5
authored
Sep 28, 2002
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use True/False everywhere.
parent
598a99c4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
Lib/email/Parser.py
Lib/email/Parser.py
+12
-5
No files found.
Lib/email/Parser.py
View file @
94f162f5
...
@@ -14,9 +14,16 @@ from email import Message
...
@@ -14,9 +14,16 @@ from email import Message
EMPTYSTRING
=
''
EMPTYSTRING
=
''
NL
=
'
\
n
'
NL
=
'
\
n
'
try
:
True
,
False
except
NameError
:
True
=
1
False
=
0
class
Parser
:
class
Parser
:
def
__init__
(
self
,
_class
=
Message
.
Message
,
strict
=
0
):
def
__init__
(
self
,
_class
=
Message
.
Message
,
strict
=
False
):
"""Parser of RFC 2822 and MIME email messages.
"""Parser of RFC 2822 and MIME email messages.
Creates an in-memory object tree representing the email message, which
Creates an in-memory object tree representing the email message, which
...
@@ -41,14 +48,14 @@ class Parser:
...
@@ -41,14 +48,14 @@ class Parser:
self
.
_class
=
_class
self
.
_class
=
_class
self
.
_strict
=
strict
self
.
_strict
=
strict
def
parse
(
self
,
fp
,
headersonly
=
0
):
def
parse
(
self
,
fp
,
headersonly
=
False
):
root
=
self
.
_class
()
root
=
self
.
_class
()
self
.
_parseheaders
(
root
,
fp
)
self
.
_parseheaders
(
root
,
fp
)
if
not
headersonly
:
if
not
headersonly
:
self
.
_parsebody
(
root
,
fp
)
self
.
_parsebody
(
root
,
fp
)
return
root
return
root
def
parsestr
(
self
,
text
,
headersonly
=
0
):
def
parsestr
(
self
,
text
,
headersonly
=
False
):
return
self
.
parse
(
StringIO
(
text
),
headersonly
=
headersonly
)
return
self
.
parse
(
StringIO
(
text
),
headersonly
=
headersonly
)
def
_parseheaders
(
self
,
container
,
fp
):
def
_parseheaders
(
self
,
container
,
fp
):
...
@@ -57,7 +64,7 @@ class Parser:
...
@@ -57,7 +64,7 @@ class Parser:
lastheader
=
''
lastheader
=
''
lastvalue
=
[]
lastvalue
=
[]
lineno
=
0
lineno
=
0
while
1
:
while
True
:
# Don't strip the line before we test for the end condition,
# Don't strip the line before we test for the end condition,
# because whitespace-only header lines are RFC compliant
# because whitespace-only header lines are RFC compliant
# continuation lines.
# continuation lines.
...
@@ -216,7 +223,7 @@ class Parser:
...
@@ -216,7 +223,7 @@ class Parser:
# by a blank line. We'll represent each header block as a
# by a blank line. We'll represent each header block as a
# separate Message object
# separate Message object
blocks
=
[]
blocks
=
[]
while
1
:
while
True
:
blockmsg
=
self
.
_class
()
blockmsg
=
self
.
_class
()
self
.
_parseheaders
(
blockmsg
,
fp
)
self
.
_parseheaders
(
blockmsg
,
fp
)
if
not
len
(
blockmsg
):
if
not
len
(
blockmsg
):
...
...
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