diff options
Diffstat (limited to 'Lib/lib2to3/main.py')
-rw-r--r-- | Lib/lib2to3/main.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Lib/lib2to3/main.py b/Lib/lib2to3/main.py index 939f4f7..b286de8 100644 --- a/Lib/lib2to3/main.py +++ b/Lib/lib2to3/main.py @@ -10,6 +10,20 @@ import optparse from . import refactor +class StdoutRefactoringTool(refactor.RefactoringTool): + """ + Prints output to stdout. + """ + + def log_error(self, msg, *args, **kwargs): + self.errors.append((msg, args, kwargs)) + self.logger.error(msg, *args, **kwargs) + + def print_output(self, lines): + for line in lines: + print(line) + + def main(fixer_pkg, args=None): """Main program. @@ -68,7 +82,7 @@ def main(fixer_pkg, args=None): fixer_names = avail_names if "all" in options.fix else explicit else: fixer_names = avail_names - rt = refactor.RefactoringTool(fixer_names, rt_opts, explicit=explicit) + rt = StdoutRefactoringTool(fixer_names, rt_opts, explicit=explicit) # Refactor all files and directories passed as arguments if not rt.errors: @@ -80,7 +94,3 @@ def main(fixer_pkg, args=None): # Return error status (0 if rt.errors is zero) return int(bool(rt.errors)) - - -if __name__ == "__main__": - sys.exit(main()) |