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
5bdb2bee
Commit
5bdb2bee
authored
Sep 28, 2002
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use True/False everywhere, and other code cleanups.
parent
e03e8f09
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
Lib/email/Utils.py
Lib/email/Utils.py
+11
-7
No files found.
Lib/email/Utils.py
View file @
5bdb2bee
...
...
@@ -21,6 +21,12 @@ from rfc822 import mktime_tz
from
rfc822
import
parsedate
as
_parsedate
from
rfc822
import
parsedate_tz
as
_parsedate_tz
try
:
True
,
False
except
NameError
:
True
=
1
False
=
0
try
:
from
quopri
import
decodestring
as
_qdecode
except
ImportError
:
...
...
@@ -30,12 +36,11 @@ except ImportError:
if
not
s
:
return
s
hasnewline
=
(
s
[
-
1
]
==
'
\
n
'
)
infp
=
StringIO
(
s
)
outfp
=
StringIO
()
_quopri
.
decode
(
infp
,
outfp
)
value
=
outfp
.
getvalue
()
if
not
hasnewline
and
value
[
-
1
]
==
'
\
n
'
:
if
not
s
.
endswith
(
'
\
n
'
)
and
value
.
endswith
(
'
\
n
'
)
:
return
value
[:
-
1
]
return
value
...
...
@@ -67,9 +72,8 @@ def _bdecode(s):
# newline". Blech!
if
not
s
:
return
s
hasnewline
=
(
s
[
-
1
]
==
'
\
n
'
)
value
=
base64
.
decodestring
(
s
)
if
not
hasnewline
and
value
[
-
1
]
==
'
\
n
'
:
if
not
s
.
endswith
(
'
\
n
'
)
and
value
.
endswith
(
'
\
n
'
)
:
return
value
[:
-
1
]
return
value
...
...
@@ -88,7 +92,7 @@ def fix_eols(s):
def
formataddr
(
pair
):
"""The inverse of parseaddr(), this takes a 2-tuple of the form
(realname, email_address) and returns the string value suitable
for an RFC 2822 From
:, To: or Cc:
.
for an RFC 2822 From
, To or Cc header
.
If the first element of pair is false, then the second element is
returned unmodified.
...
...
@@ -170,7 +174,7 @@ def encode(s, charset='iso-8859-1', encoding='q'):
def
formatdate
(
timeval
=
None
,
localtime
=
0
):
def
formatdate
(
timeval
=
None
,
localtime
=
False
):
"""Returns a date string as specified by RFC 2822, e.g.:
Fri, 09 Nov 2001 01:08:47 -0000
...
...
@@ -178,7 +182,7 @@ def formatdate(timeval=None, localtime=0):
Optional timeval if given is a floating point time value as accepted by
gmtime() and localtime(), otherwise the current time is used.
Optional localtime is a flag that when
t
rue, interprets timeval, and
Optional localtime is a flag that when
T
rue, interprets timeval, and
returns a date relative to the local timezone instead of UTC, properly
taking daylight savings time into account.
"""
...
...
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