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/register.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/register.py')
| -rw-r--r-- | Lib/packaging/command/register.py | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/Lib/packaging/command/register.py b/Lib/packaging/command/register.py index 962afdcc..006dfdf 100644 --- a/Lib/packaging/command/register.py +++ b/Lib/packaging/command/register.py @@ -10,7 +10,7 @@ import urllib.request from packaging import logger from packaging.util import (read_pypirc, generate_pypirc, DEFAULT_REPOSITORY, - DEFAULT_REALM, get_pypirc_path) + DEFAULT_REALM, get_pypirc_path, encode_multipart) from packaging.command.cmd import Command class register(Command): @@ -231,29 +231,11 @@ Your selection [default 1]: ''') if 'name' in data: logger.info('Registering %s to %s', data['name'], self.repository) # Build up the MIME payload for the urllib2 POST data - boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254' - sep_boundary = '\n--' + boundary - end_boundary = sep_boundary + '--' - body = io.StringIO() - for key, value in data.items(): - # handle multiple entries for the same name - if not isinstance(value, (tuple, list)): - value = [value] - - for value in value: - body.write(sep_boundary) - body.write('\nContent-Disposition: form-data; name="%s"'%key) - body.write("\n\n") - body.write(value) - if value and value[-1] == '\r': - body.write('\n') # write an extra newline (lurve Macs) - body.write(end_boundary) - body.write("\n") - body = body.getvalue() + content_type, body = encode_multipart(data.items(), []) # build the Request headers = { - 'Content-type': 'multipart/form-data; boundary=%s; charset=utf-8'%boundary, + 'Content-type': content_type, 'Content-length': str(len(body)) } req = urllib.request.Request(self.repository, body, headers) |
