# 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]
                       [-f {no_change,fit,fitsum,gen,gensum,grph,n2pdat,p2ndat,msim,rst,sim,sumdoc,tut,tutsum,val,vpc,mfit,mgen,mtut,mcomp}]
                       [-i] [-d] [-a] [-c] [-l] [-o] [-s]
                       [-v {noset,info,debug,warning,error,critical}]
                       input_file

    Tries to reformat an old version of a PoPy script

    positional arguments:
      input_file            Required path to input configuration file.

    optional arguments:
      -h, --help            show this help message and exit
      -f {no_change,fit,fitsum,gen,gensum,grph,n2pdat,p2ndat,msim,rst,sim,sumdoc,tut,tutsum,val,vpc,mfit,mgen,mtut,mcomp}, --force_type {no_change,fit,fitsum,gen,gensum,grph,n2pdat,p2ndat,msim,rst,sim,sumdoc,tut,tutsum,val,vpc,mfit,mgen,mtut,mcomp}
                            Optionally force the input config file to be a certain
                            type of script, by default no change.
      -i, --inplace         Optionally overwrite original file, i.e fix in place.
      -d, --delete          Optionally delete extra files, e.g. log + backup file
                            etc.
      -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.
      -o, --overwrite       Optionally overwrite existing output files without
                            asking.
      -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