On this page |
Synopsis ¶
py23convert [-h] [-v] [-d] [-i] [-l] [-a] [-t] [-s TAB_WIDTH] [-j N_PROCESSES] [directory|file [directory|file ...]]
Description ¶
py23convert converts Python in HDAs and/or Python files from Python 2 to Python 2/3 using futurize. This script can accept Python files, expanded HDA directories, or HDA files. HDA files must be in the format <name>.hda. By default, copies are made of the input files/directories, and the copies are converted.
Files are copied with '_converted' added just before the last '.' in the file name. Directories are copied with '_converted' as a suffix.
Several futurize transformations are skipped by default to avoid adding imports from modules other than future. The script also has an additional optional transformation available which will convert tabs in leading whitespace to spaces.
Options ¶
-h
Displays help and usage information.
-v
Show the diffs of the changes being made.
-d
Only show the diffs of the changes that would be made, do not actually make any changes.
-i
Overwrite the source files/directories with the converted versions.
-l
List available transformations. Note that several transformations are skipped to avoid adding imports from modules other than future.
-a
Run all futurize transformations. Note that this may introduce imports from modules other than future.
-t
Replace all tabs used in leading whitespace with spaces. Tabs are replaced from left to right by 1 to TAB_WIDTH spaces such that the number of characters up to and including the replacement is a multiple of TAB_WIDTH. By default, TAB_WIDTH is 8, but can be set using the –spaces-per-tab option.
-s
Set the number of spaces that one tab is equal to. This value is used by
the optional fixer specified by --fix-tabs
. By default the tab with is
8.
-j
Run n fixers concurrently. By default the number of processes is 4.
Examples ¶
To convert a single hda:
py23convert asset.hda
To convert a single hda in-place:
py23convert -i asset.hda
To convert an entire directory of hdas:
py23convert *.hda