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
b17be6c0
Commit
b17be6c0
authored
Jul 11, 1997
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the modules base64, quopri, and uu, instead of external programs
to decode/encode the standard transfer encodings.
parent
d3d9cfe1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
Lib/mimetools.py
Lib/mimetools.py
+22
-2
No files found.
Lib/mimetools.py
View file @
b17be6c0
...
@@ -131,9 +131,16 @@ def choose_boundary():
...
@@ -131,9 +131,16 @@ def choose_boundary():
# Subroutines for decoding some common content-transfer-types
# Subroutines for decoding some common content-transfer-types
# XXX This requires that uudecode and mmencode are in $PATH
def
decode
(
input
,
output
,
encoding
):
def
decode
(
input
,
output
,
encoding
):
if
encoding
==
'base64'
:
import
base64
return
base64
.
decode
(
input
,
output
)
if
encoding
==
'quoted-printable'
:
import
quopri
return
quopri
.
decode
(
input
,
output
)
if
encoding
in
(
'uuencode'
,
'x-uuencode'
):
import
uu
return
uu
.
decode
(
input
,
output
)
if
decodetab
.
has_key
(
encoding
):
if
decodetab
.
has_key
(
encoding
):
pipethrough
(
input
,
decodetab
[
encoding
],
output
)
pipethrough
(
input
,
decodetab
[
encoding
],
output
)
else
:
else
:
...
@@ -141,12 +148,25 @@ def decode(input, output, encoding):
...
@@ -141,12 +148,25 @@ def decode(input, output, encoding):
'unknown Content-Transfer-Encoding: %s'
%
encoding
'unknown Content-Transfer-Encoding: %s'
%
encoding
def
encode
(
input
,
output
,
encoding
):
def
encode
(
input
,
output
,
encoding
):
if
encoding
==
'base64'
:
import
base64
return
base64
.
encode
(
input
,
output
)
if
encoding
==
'quoted-printable'
:
import
quopri
return
quopri
.
encode
(
input
,
output
,
0
)
if
encoding
in
(
'uuencode'
,
'x-uuencode'
):
import
uu
return
uu
.
encode
(
input
,
output
)
if
encodetab
.
has_key
(
encoding
):
if
encodetab
.
has_key
(
encoding
):
pipethrough
(
input
,
encodetab
[
encoding
],
output
)
pipethrough
(
input
,
encodetab
[
encoding
],
output
)
else
:
else
:
raise
ValueError
,
\
raise
ValueError
,
\
'unknown Content-Transfer-Encoding: %s'
%
encoding
'unknown Content-Transfer-Encoding: %s'
%
encoding
# The following is no longer used for standard encodings
# XXX This requires that uudecode and mmencode are in $PATH
uudecode_pipe
=
'''(
uudecode_pipe
=
'''(
TEMP=/tmp/@uu.$$
TEMP=/tmp/@uu.$$
sed "s%^begin [0-7][0-7]* .*%begin 600 $TEMP%" | uudecode
sed "s%^begin [0-7][0-7]* .*%begin 600 $TEMP%" | uudecode
...
...
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