diff options
Diffstat (limited to 'Lib/distutils/command/upload.py')
| -rw-r--r-- | Lib/distutils/command/upload.py | 48 | 
1 files changed, 24 insertions, 24 deletions
| diff --git a/Lib/distutils/command/upload.py b/Lib/distutils/command/upload.py index d6762e4..b906435 100644 --- a/Lib/distutils/command/upload.py +++ b/Lib/distutils/command/upload.py @@ -1,24 +1,21 @@ -"""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). +""" -from distutils.errors import * -from distutils.core import PyPIRCCommand -from distutils.spawn import spawn -from distutils import log -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 - -# this keeps compatibility for 2.3 and 2.4 -if sys.version < "2.5": -    from md5 import md5 -else: -    from hashlib import md5 +from distutils.errors import DistutilsOptionError +from distutils.core import PyPIRCCommand +from distutils.spawn import spawn +from distutils import log  class upload(PyPIRCCommand): @@ -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 = '\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: @@ -167,13 +165,15 @@ class upload(PyPIRCCommand):          body.write(b"\n")          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) | 
