popy format
Occasionally, we make changes to the Script File Formats that render old script files defunct. So that you do not need to rewrite all of your old script files, we provide a tool called popy format that reads in the old-style script file and outputs it with the new format.
Format a script
Do this by opening a Open a PoPy Command Prompt and typing:-
popy format my_script.pyml
which will output a new version of my_script.pyml called my_script.pyml.new.
You can also edit the script ‘inplace’ using:-
popy format -i my_script.pyml
This creates a backup file called ‘my_script.pyml.old’ and updates the format of ‘my_script.pyml’ directly. See Command line options for other options.
The output of popy format may need to be manually edited to obtain desired results (e.g. to change from the default value for newly added options).
As usual, a log file will be created to document the formatting process.
Format multiple scripts
Note you can also format all scripts in a directory using:-
popy format *.pyml
This formats all files with the ‘.pyml’ extension in serial.
Command line options
usage: popy_format [-h] [-t] [-v {noset,info,debug,warning,error,critical}]
[-a] [-c] [-l] [-s] [-o] [--inplace] [-d]
script_path
Tries to reformat an old version of a PoPy script.
positional arguments:
script_path Required path to configuration file.
options:
-h, --help show this help message and exit
-t, --timestamp Optionally included timestamp string in log file name
and output folder name.
-v {noset,info,debug,warning,error,critical}, --verbosity {noset,info,debug,warning,error,critical}
verbosity of output in log files
-a, --all_config Optionally output all possible config file entries in
output script files. If set to false, the default
entries with default values are suppressed for the
sake of brevity.
-c, --comment_scripts
Optionally add explanatory comments to all entries in
output script files.
-l, --line_breaks Optionally enforce line breaks in the config file.
This increases the length of files, but may improve
clarity. If set to False, short dictionary lines are
compacted instead using {} notation.
-s, --spaces Optionally add more spaces to the output config file
for greater clarity, but longer config files. Off by
default.
-o, --overwrite Optionally overwrite existing output files without
asking.
--inplace Optionally overwrite original file, i.e fix in place.
-d, --delete Optionally delete extra files, e.g. log + backup file
etc.