2013-01-30 20:10:48 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import os
|
2012-08-05 12:32:57 +02:00
|
|
|
import sys
|
2013-01-30 20:10:48 +01:00
|
|
|
import shutil
|
|
|
|
from glob import glob
|
|
|
|
try:
|
|
|
|
from lib2to3.main import main
|
|
|
|
except ImportError:
|
|
|
|
print('Error: you need the 2to3 tool to run this script.')
|
|
|
|
os.chdir(os.path.join(os.path.dirname(__file__), '..'))
|
|
|
|
try:
|
|
|
|
os.unlink('src/version.py')
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
shutil.rmtree('py3k')
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
os.mkdir('py3k')
|
2013-02-22 21:26:26 +01:00
|
|
|
for dirname in ('locales', 'docs', 'plugins', 'src', 'test', 'scripts'):
|
2013-01-30 20:10:48 +01:00
|
|
|
shutil.copytree(dirname, os.path.join('py3k', dirname))
|
2013-02-22 21:17:55 +01:00
|
|
|
for filename in ('setup.py',):
|
|
|
|
shutil.copyfile(filename, os.path.join('py3k', filename))
|
|
|
|
os.chdir('py3k')
|
2013-01-30 20:10:48 +01:00
|
|
|
|
|
|
|
files = ['run.py', 'src', 'plugins', 'test', 'setup.py'] + glob('scripts/*')
|
2013-02-22 21:17:55 +01:00
|
|
|
args = ['-wn']
|
2013-01-30 20:10:48 +01:00
|
|
|
fixers = []
|
2013-07-15 13:34:47 +02:00
|
|
|
for fix in ['all', 'def_iteritems', 'def_itervalues', 'def_iterkeys', 'reload', 'import']:
|
2013-01-30 20:10:48 +01:00
|
|
|
fixers += ['-f', fix]
|
|
|
|
sys.argv = files + args + fixers + sys.argv
|
|
|
|
sys.argc = len(sys.argv)
|
2012-08-05 12:32:57 +02:00
|
|
|
|
2013-07-15 13:34:47 +02:00
|
|
|
from . import fix_def_iteritems, fix_def_itervalues, fix_def_iterkeys, fix_reload, fix_import
|
2012-08-05 12:32:57 +02:00
|
|
|
|
|
|
|
# Hacks
|
|
|
|
sys.modules['lib2to3.fixes.fix_def_iteritems'] = fix_def_iteritems
|
|
|
|
sys.modules['lib2to3.fixes.fix_def_itervalues'] = fix_def_itervalues
|
|
|
|
sys.modules['lib2to3.fixes.fix_def_iterkeys'] = fix_def_iterkeys
|
2012-08-05 13:28:09 +02:00
|
|
|
sys.modules['lib2to3.fixes.fix_reload'] = fix_reload
|
2013-07-15 13:34:47 +02:00
|
|
|
sys.modules['lib2to3.fixes.fix_import'] = fix_import
|
2012-08-05 12:32:57 +02:00
|
|
|
|
|
|
|
sys.exit(main("lib2to3.fixes"))
|