• Language: en

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

Note: "popy_format ..." will be deprecated in favour of "popy format ..." from v1.3

usage: popy_format [-h] [-t] [-a] [-c] [-l] [-s]
                   [-v {noset,info,debug,warning,error,critical}] [-o]
                   [--inplace] [-d]
                   script_path

Tries to reformat an old version of a PoPy script.

positional arguments:
  script_path           Required path to configuration file.

optional arguments:
  -h, --help            show this help message and exit
  -t, --timestamp       Optionally included timestamp string in log file name
                        and output folder name.
  -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.
  -v {noset,info,debug,warning,error,critical}, --verbosity {noset,info,debug,warning,error,critical}
                        verbosity of output in log file
  -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.
Back to Top