diff options
| author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2011-03-15 14:36:55 -0400 |
|---|---|---|
| committer | Vitaly Babiy <vbabiy86@gmail.com> | 2011-03-15 14:55:46 -0400 |
| commit | 10ba3f3cc0d7a254dd72e2bb9557006da2f85e00 (patch) | |
| tree | bde202c836eaba0447b8c160c2e6e975d855f237 /bin | |
| parent | 56748c1f68812a8bc40d92f53fc87693ba5b4e83 (diff) | |
| download | virtualenv-10ba3f3cc0d7a254dd72e2bb9557006da2f85e00.tar.gz | |
Port to python3
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/rebuild-script.py | 17 | ||||
| -rwxr-xr-x | bin/refresh-support-files.py | 17 |
2 files changed, 19 insertions, 15 deletions
diff --git a/bin/rebuild-script.py b/bin/rebuild-script.py index ae94826..4244add 100755 --- a/bin/rebuild-script.py +++ b/bin/rebuild-script.py @@ -5,6 +5,7 @@ Helper script to rebuild virtualenv.py from virtualenv_support import re import os +import sys here = os.path.dirname(__file__) script = os.path.join(here, '..', 'virtualenv.py') @@ -28,17 +29,17 @@ def rebuild(): filename = match.group(1) varname = match.group(2) data = match.group(3) - print 'Found reference to file %s' % filename + print('Found reference to file %s' % filename) f = open(os.path.join(here, '..', 'virtualenv_support', filename), 'rb') c = f.read() f.close() new_data = c.encode('zlib').encode('base64') if new_data == data: - print ' Reference up to date (%s bytes)' % len(c) + print(' Reference up to date (%s bytes)' % len(c)) parts.append(match.group(0)) continue - print ' Content changed (%s bytes -> %s bytes)' % ( - zipped_len(data), len(c)) + print(' Content changed (%s bytes -> %s bytes)' % ( + zipped_len(data), len(c))) new_match = file_template % dict( filename=filename, varname=varname, @@ -47,15 +48,15 @@ def rebuild(): parts.append(content[last_pos:]) new_content = ''.join(parts) if new_content != content: - print 'Content updated; overwriting...', + sys.stdout.write('Content updated; overwriting... ') f = open(script, 'wb') f.write(new_content) f.close() - print 'done.' + print('done.') else: - print 'No changes in content' + print('No changes in content') if match is None: - print 'No variables were matched/found' + print('No variables were matched/found') def zipped_len(data): if not data: diff --git a/bin/refresh-support-files.py b/bin/refresh-support-files.py index c634040..f7ac7e8 100755 --- a/bin/refresh-support-files.py +++ b/bin/refresh-support-files.py @@ -4,7 +4,10 @@ Refresh any files in ../virtualenv_support/ that come from elsewhere """ import os -import urllib +try: + from urllib.request import urlopen +except ImportError: + from urllib2 import urlopen import sys here = os.path.dirname(__file__) @@ -17,17 +20,17 @@ files = [ ('http://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c11-py2.4.egg', 'setuptools-0.6c11-py2.4.egg'), ('http://python-distribute.org/distribute_setup.py', 'distribute_setup.py'), ('http://pypi.python.org/packages/source/d/distribute/distribute-0.6.14.tar.gz', 'distribute-0.6.14.tar.gz'), - ('http://pypi.python.org/packages/source/p/pip/pip-0.8.3.tar.gz', 'pip-0.8.3.tar.gz'), + ('http://pypi.python.org/packages/source/p/pip/pip-0.8.2.tar.gz', 'pip-0.8.2.tar.gz'), ] def main(): for url, filename in files: - print 'fetching', url, '...', + sys.stdout.write('fetching %s ... ' % url) sys.stdout.flush() - f = urllib.urlopen(url) + f = urlopen(url) content = f.read() f.close() - print 'done.' + print('done.') filename = os.path.join(support_files, filename) if os.path.exists(filename): f = open(filename, 'rb') @@ -36,9 +39,9 @@ def main(): else: cur_content = '' if cur_content == content: - print ' %s up-to-date' % filename + print(' %s up-to-date' % filename) else: - print ' overwriting %s' % filename + print(' overwriting %s' % filename) f = open(filename, 'wb') f.write(content) f.close() |
