summaryrefslogtreecommitdiff
path: root/Lib/distutils/command/upload.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/distutils/command/upload.py')
-rw-r--r--Lib/distutils/command/upload.py40
1 files changed, 20 insertions, 20 deletions
diff --git a/Lib/distutils/command/upload.py b/Lib/distutils/command/upload.py
index 1a96e2221e..1c4fc48a12 100644
--- a/Lib/distutils/command/upload.py
+++ b/Lib/distutils/command/upload.py
@@ -1,11 +1,14 @@
-"""distutils.command.upload
+"""
+distutils.command.upload
-Implements the Distutils 'upload' subcommand (upload package to PyPI)."""
+Implements the Distutils 'upload' subcommand (upload package to a package
+index).
+"""
-import sys
-import os, io
-import socket
+import os
+import io
import platform
+import hashlib
from base64 import standard_b64encode
from urllib.request import urlopen, Request, HTTPError
from urllib.parse import urlparse
@@ -14,12 +17,6 @@ from distutils.core import PyPIRCCommand
from distutils.spawn import spawn
from distutils import log
-# this keeps compatibility for 2.3 and 2.4
-if sys.version < "2.5":
- from md5 import md5
-else:
- from hashlib import md5
-
class upload(PyPIRCCommand):
description = "upload binary package to PyPI"
@@ -60,7 +57,8 @@ class upload(PyPIRCCommand):
def run(self):
if not self.distribution.dist_files:
- raise DistutilsOptionError("No dist file created in earlier command")
+ msg = "No dist file created in earlier command"
+ raise DistutilsOptionError(msg)
for command, pyversion, filename in self.distribution.dist_files:
self.upload_file(command, pyversion, filename)
@@ -103,10 +101,10 @@ class upload(PyPIRCCommand):
'content': (os.path.basename(filename),content),
'filetype': command,
'pyversion': pyversion,
- 'md5_digest': md5(content).hexdigest(),
+ 'md5_digest': hashlib.md5(content).hexdigest(),
# additional meta-data
- 'metadata_version' : '1.0',
+ 'metadata_version': '1.0',
'summary': meta.get_description(),
'home_page': meta.get_url(),
'author': meta.get_contact(),
@@ -149,7 +147,7 @@ class upload(PyPIRCCommand):
for key, value in data.items():
title = '\r\nContent-Disposition: form-data; name="%s"' % key
# handle multiple entries for the same name
- if type(value) != type([]):
+ if not isinstance(value, list):
value = [value]
for value in value:
if type(value) is tuple:
@@ -166,13 +164,15 @@ class upload(PyPIRCCommand):
body.write(end_boundary)
body = body.getvalue()
- self.announce("Submitting %s to %s" % (filename, self.repository), log.INFO)
+ msg = "Submitting %s to %s" % (filename, self.repository)
+ self.announce(msg, log.INFO)
# build the Request
- headers = {'Content-type':
- 'multipart/form-data; boundary=%s' % boundary,
- 'Content-length': str(len(body)),
- 'Authorization': auth}
+ headers = {
+ 'Content-type': 'multipart/form-data; boundary=%s' % boundary,
+ 'Content-length': str(len(body)),
+ 'Authorization': auth,
+ }
request = Request(self.repository, data=body,
headers=headers)