diff options
author | Gregory P. Smith <greg@krypto.org> | 2012-02-12 23:50:21 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@krypto.org> | 2012-02-12 23:50:21 (GMT) |
commit | 58f23ffb21b0fadb8df91c7c9735401f50b3e844 (patch) | |
tree | ef26a40799350fb1d788a1e05212810a1f5a4c5f /Doc/library | |
parent | 51d04d1ba8643d8a0c89d8307bf43697223f31e2 (diff) | |
download | cpython-58f23ffb21b0fadb8df91c7c9735401f50b3e844.zip cpython-58f23ffb21b0fadb8df91c7c9735401f50b3e844.tar.gz cpython-58f23ffb21b0fadb8df91c7c9735401f50b3e844.tar.bz2 |
Issue #13930: Adds ability for 2to3 to write its output to a different
directory tree instead of overwriting the input files. Adds three command
line options: -o/--output-dir, -W/--write-unchanged-files and --add-suffix.
Feature backports into stable release branches for 2to3 are allowed by
a special exemption:
http://mail.python.org/pipermail/python-dev/2011-December/115089.html
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/2to3.rst | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Doc/library/2to3.rst b/Doc/library/2to3.rst index fe1c2be..a13fb65 100644 --- a/Doc/library/2to3.rst +++ b/Doc/library/2to3.rst @@ -94,6 +94,38 @@ change can also be enabled manually with the :option:`-p` flag. Use :option:`-p` to run fixers on code that already has had its print statements converted. +The :option:`-o` or :option:`--output-dir` option allows specification of an +alternate directory for processed output files to be written to. The +:option:`-n` flag is required when using this as backup files do not make sense +when not overwriting the input files. + +.. versionadded:: 3.2.3 + The :option:`-o` option was added. + +The :option:`-W` or :option:`--write-unchanged-files` flag tells 2to3 to always +write output files even if no changes were required to the file. This is most +useful with :option:`-o` so that an entire Python source tree is copied with +translation from one directory to another. +This option implies the :option:`-w` flag as it would not make sense otherwise. + +.. versionadded:: 3.2.3 + The :option:`-W` flag was added. + +The :option:`--add-suffix` option specifies a string to append to all output +filenames. The :option:`-n` flag is required when specifying this as backups +are not necessary when writing to different filenames. Example:: + + $ 2to3 -n -W --add-suffix=3 example.py + +Will cause a converted file named ``example.py3`` to be written. + +.. versionadded:: 3.2.3 + The :option:`--add-suffix` option was added. + +To translate an entire project from one directory tree to another use:: + + $ 2to3 --output-dir=python3-version/mycode -W -n python2-version/mycode + .. _2to3-fixers: |