1- #!/usr/bin/env python
1+ #!/usr/bin/env python3
22# TODO: Upload to GitHub releases
33# TODO: .pypirc configuration
4- from __future__ import print_function
5-
64import argparse
75import json
86import os
97import os .path
108import shutil
119import subprocess
10+ from urllib .parse import urljoin
11+ from urllib .request import urlopen
1212
13- from six .moves .urllib .parse import urljoin
14- from six .moves .urllib .request import urlopen
1513from twine .commands import upload
1614
1715
2725
2826def ci_builds ():
2927 response = urlopen (APPVEYOR_API_BUILDS_URL )
30- projects = json .loads (response . read (). decode ( 'utf-8' )) # py3 compat
28+ projects = json .load (response )
3129 response .close ()
3230 return projects ['builds' ]
3331
@@ -62,7 +60,7 @@ def read(tag):
6260def ci_jobs (build ):
6361 url = urljoin (APPVEYOR_API_JOBS_URL , build ['version' ])
6462 response = urlopen (url )
65- build = json .loads (response . read (). decode ( 'utf-8' )) # py3 compat
63+ build = json .load (response )
6664 response .close ()
6765 return build ['build' ]['jobs' ]
6866
@@ -71,15 +69,15 @@ def ci_artifacts(job):
7169 url = urljoin (urljoin (APPVEYOR_API_JOB_URL , job ['jobId' ] + '/' ),
7270 'artifacts/' )
7371 response = urlopen (url )
74- files = json .loads (response . read (). decode ( 'utf-8' )) # py3 compat
72+ files = json .load (response )
7573 response .close ()
7674 for file_ in files :
7775 file_ ['url' ] = urljoin (url , file_ ['fileName' ])
7876 return files
7977
8078
8179def download_artifact (artifact , target_dir , overwrite = False ):
82- print ('Downloading {0 }...' .format (artifact ['fileName' ]))
80+ print ('Downloading {}...' .format (artifact ['fileName' ]))
8381 response = urlopen (artifact ['url' ])
8482 filename = os .path .basename (artifact ['fileName' ])
8583 target_path = os .path .join (target_dir , filename )
@@ -123,7 +121,7 @@ def main():
123121 for artifact in artifacts :
124122 dist = download_artifact (artifact , args .dist_dir , args .overwrite )
125123 dists .append (dist )
126- print ('Uploading {0 } file(s)...' .format (len (dists )))
124+ print ('Uploading {} file(s)...' .format (len (dists )))
127125 upload .main (('-r' , 'pypi' ) + tuple (dists ))
128126
129127
0 commit comments