diff options
| author | Benjamin Peterson <benjamin@python.org> | 2011-07-08 18:39:56 (GMT) |
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2011-07-08 18:39:56 (GMT) |
| commit | 910789f10fb314fe7149be84aa57d6ec12ad4a7b (patch) | |
| tree | a658027493df6d758e5d0b802ffa72e66594ad1e /Lib/packaging/command/upload_docs.py | |
| parent | ae10c0653e5469e7f41f12cee35bfe653a389cbc (diff) | |
| parent | 4a183b47f353a25b76aaaf1b7043458dbcab8890 (diff) | |
| download | cpython-910789f10fb314fe7149be84aa57d6ec12ad4a7b.zip cpython-910789f10fb314fe7149be84aa57d6ec12ad4a7b.tar.gz cpython-910789f10fb314fe7149be84aa57d6ec12ad4a7b.tar.bz2 | |
merge heads
Diffstat (limited to 'Lib/packaging/command/upload_docs.py')
| -rw-r--r-- | Lib/packaging/command/upload_docs.py | 46 |
1 files changed, 2 insertions, 44 deletions
diff --git a/Lib/packaging/command/upload_docs.py b/Lib/packaging/command/upload_docs.py index 47e6217..03dd3ec 100644 --- a/Lib/packaging/command/upload_docs.py +++ b/Lib/packaging/command/upload_docs.py @@ -10,7 +10,8 @@ import urllib.parse from io import BytesIO from packaging import logger -from packaging.util import read_pypirc, DEFAULT_REPOSITORY, DEFAULT_REALM +from packaging.util import (read_pypirc, DEFAULT_REPOSITORY, DEFAULT_REALM, + encode_multipart) from packaging.errors import PackagingFileError from packaging.command.cmd import Command @@ -28,49 +29,6 @@ def zip_dir(directory): return destination -# grabbed from -# http://code.activestate.com/recipes/ -# 146306-http-client-to-post-using-multipartform-data/ -# TODO factor this out for use by install and command/upload - -def encode_multipart(fields, files, boundary=None): - """ - *fields* is a sequence of (name: str, value: str) elements for regular - form fields, *files* is a sequence of (name: str, filename: str, value: - bytes) elements for data to be uploaded as files. - - Returns (content_type: bytes, body: bytes) ready for http.client.HTTP. - """ - if boundary is None: - boundary = b'--------------GHSKFJDLGDS7543FJKLFHRE75642756743254' - elif not isinstance(boundary, bytes): - raise TypeError('boundary is not bytes but %r' % type(boundary)) - - l = [] - for key, value in fields: - l.extend(( - b'--' + boundary, - ('Content-Disposition: form-data; name="%s"' % - key).encode('utf-8'), - b'', - value.encode('utf-8'))) - - for key, filename, value in files: - l.extend(( - b'--' + boundary, - ('Content-Disposition: form-data; name="%s"; filename="%s"' % - (key, filename)).encode('utf-8'), - b'', - value)) - l.append(b'--' + boundary + b'--') - l.append(b'') - - body = b'\r\n'.join(l) - - content_type = b'multipart/form-data; boundary=' + boundary - return content_type, body - - class upload_docs(Command): description = "upload HTML documentation to PyPI" |
