Only in lib2to3-new/: Grammar3.1.1.final.0.pickle Only in lib2to3-new/: PatternGrammar3.1.1.final.0.pickle Only in lib2to3-new/: caching.py diff -ur lib2to3-orig/main.py lib2to3-new/main.py --- lib2to3-orig/main.py 2010-01-31 16:49:31.000000000 -0800 +++ lib2to3-new/main.py 2010-01-31 17:12:12.000000000 -0800 @@ -10,7 +10,7 @@ import optparse from . import refactor - +from . import caching def diff_texts(a, b, filename): """Return a unified diff of two strings.""" @@ -73,7 +73,7 @@ print("WARNING: %s" % (msg,), file=sys.stderr) -def main(fixer_pkg, args=None): +def main(fixer_pkg, args=None, refactoring_tool_cls=StdoutRefactoringTool): """Main program. Args: @@ -105,6 +105,11 @@ help="Write back modified files") parser.add_option("-n", "--nobackups", action="store_true", default=False, help="Don't write backups for modified files.") + parser.add_option("--cache-dir", action="store", default=None, + help="Directory to use as a cache for translation using " + "the MD5 of the source to lookup previous conversions. " + "Use at your own risk; the environment variable " + "PY2TO3_CACHEDIR can also be set instead.") # Parse command line arguments refactor_stdin = False @@ -132,6 +137,14 @@ if options.print_function: flags["print_function"] = True + cachedir = options.cache_dir + if cachedir is None: + cachedir = os.environ.get("PY2TO3_CACHEDIR") + if cachedir: + flags['cachedir'] = os.path.abspath(cachedir) + refactoring_tool_cls = caching.CachingMixin.derive_cls( + refactoring_tool_cls) + # Set up logging handler level = logging.DEBUG if options.verbose else logging.INFO logging.basicConfig(format='%(name)s: %(message)s', level=level) @@ -151,7 +164,7 @@ else: requested = avail_fixes.union(explicit) fixer_names = requested.difference(unwanted_fixes) - rt = StdoutRefactoringTool(sorted(fixer_names), flags, sorted(explicit), + rt = refactoring_tool_cls(sorted(fixer_names), flags, sorted(explicit), options.nobackups, not options.no_diffs) # Refactor all files and directories passed as arguments