Commit f6a06d79 authored by Martin v. Löwis's avatar Martin v. Löwis

Issue #4072: Restore build_py_2to3. Add a distutils demo for

build_py_2to3.
parent 9dda0b58
...@@ -384,6 +384,18 @@ class build_py (Command): ...@@ -384,6 +384,18 @@ class build_py (Command):
byte_compile(files, optimize=self.optimize, byte_compile(files, optimize=self.optimize,
force=self.force, prefix=prefix, dry_run=self.dry_run) force=self.force, prefix=prefix, dry_run=self.dry_run)
from lib2to3.refactor import RefactoringTool, get_fixers_from_package
class DistutilsRefactoringTool(RefactoringTool):
def log_error(self, msg, *args, **kw):
# XXX ignores kw
log.error(msg, *args)
def log_message(self, msg, *args):
log.info(msg, *args)
def log_debug(self, msg, *args):
log.debug(msg, *args)
class build_py_2to3(build_py): class build_py_2to3(build_py):
def run(self): def run(self):
self.updated_files = [] self.updated_files = []
...@@ -396,18 +408,12 @@ class build_py_2to3(build_py): ...@@ -396,18 +408,12 @@ class build_py_2to3(build_py):
self.build_package_data() self.build_package_data()
# 2to3 # 2to3
from lib2to3.refactor import RefactoringTool fixers = get_fixers_from_package('lib2to3.fixes')
class Options: options = dict(fix=[], list_fixes=[],
pass print_function=False, verbose=False,
o = Options() write=True)
o.doctests_only = False r = DistutilsRefactoringTool(fixers, options)
o.fix = [] r.refactor(self.updated_files, write=True)
o.list_fixes = []
o.print_function = False
o.verbose = False
o.write = True
r = RefactoringTool(o)
r.refactor_args(self.updated_files)
# Remaining base class code # Remaining base class code
self.byte_compile(self.get_outputs(include_bytecode=0)) self.byte_compile(self.get_outputs(include_bytecode=0))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment