Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
daf695c9
Commit
daf695c9
authored
May 31, 2016
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use bytes literals and simpler encoding logic when constructing multipart post
parent
a797c9be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
20 deletions
+14
-20
setuptools/command/upload_docs.py
setuptools/command/upload_docs.py
+14
-20
No files found.
setuptools/command/upload_docs.py
View file @
daf695c9
...
...
@@ -21,15 +21,9 @@ from pkg_resources import iter_entry_points
from
.upload
import
upload
errors
=
'surrogateescape'
if
six
.
PY3
else
'strict'
# This is not just a replacement for byte literals
# but works as a general purpose encoder
def
b
(
s
,
encoding
=
'utf-8'
):
if
isinstance
(
s
,
six
.
text_type
):
return
s
.
encode
(
encoding
,
errors
)
return
s
def
_encode
(
s
):
errors
=
'surrogateescape'
if
six
.
PY3
else
'strict'
return
s
.
encode
(
'utf-8'
,
errors
)
class
upload_docs
(
upload
):
...
...
@@ -111,16 +105,16 @@ class upload_docs(upload):
'content'
:
(
os
.
path
.
basename
(
filename
),
content
),
}
# set up the authentication
credentials
=
b
(
self
.
username
+
':'
+
self
.
password
)
credentials
=
_encode
(
self
.
username
+
':'
+
self
.
password
)
credentials
=
standard_b64encode
(
credentials
)
if
six
.
PY3
:
credentials
=
credentials
.
decode
(
'ascii'
)
auth
=
"Basic "
+
credentials
# Build up the MIME payload for the POST data
boundary
=
'--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
sep_boundary
=
b
(
'
\
n
--'
)
+
b
(
boundary
)
end_boundary
=
sep_boundary
+
b
(
'--'
)
boundary
=
b
'--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
sep_boundary
=
b
'
\
n
--'
+
boundary
end_boundary
=
sep_boundary
+
b
'--'
body
=
[]
for
key
,
values
in
six
.
iteritems
(
data
):
title
=
'
\
n
Content-Disposition: form-data; name="%s"'
%
key
...
...
@@ -132,16 +126,16 @@ class upload_docs(upload):
title
+=
'; filename="%s"'
%
value
[
0
]
value
=
value
[
1
]
else
:
value
=
b
(
value
)
value
=
_encode
(
value
)
body
.
append
(
sep_boundary
)
body
.
append
(
b
(
title
))
body
.
append
(
b
(
"
\
n
\
n
"
)
)
body
.
append
(
_encode
(
title
))
body
.
append
(
b
"
\
n
\
n
"
)
body
.
append
(
value
)
if
value
and
value
[
-
1
:]
==
b
(
'
\
r
'
)
:
body
.
append
(
b
(
'
\
n
'
)
)
# write an extra newline (lurve Macs)
if
value
and
value
[
-
1
:]
==
b
'
\
r
'
:
body
.
append
(
b
'
\
n
'
)
# write an extra newline (lurve Macs)
body
.
append
(
end_boundary
)
body
.
append
(
b
(
"
\
n
"
)
)
body
=
b
(
''
)
.
join
(
body
)
body
.
append
(
b
"
\
n
"
)
body
=
b
''
.
join
(
body
)
self
.
announce
(
"Submitting documentation to %s"
%
(
self
.
repository
),
log
.
INFO
)
...
...
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