38. parser — pyFormex command line options

This module defines the pyFormex command line options. It is placed in a separate module so that it has very limited dependencies and can be loaded very early in the startup procedure. This allows options to be used to influence the further startup process and the modules that are imported.

38.1. Classes defined in module parser

class parser.DescriptionHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None)[source]

Help message formatter which retains some formatting in descriptions.

The default argparse.HelpFormatter removes all newlines and wraps the text. The optional argparse.RawDescriptionHelpFormatter keeps everything as is, without any wrapping.

This class is a combination of both, allowing text wrapping while still having the possibility of paragraphs and raw formatted sections. It splits the text in parts (paragraphs) at double newlines (’nn’). Parts starting with ‘<raw>’ are then formatted as raw text (with the ‘<raw>’ removed), while other parts are formatted as wrapped text. The results are joined with a newline. Use four newlines to create an empty line in the output.

38.2. Functions defined in module parser

parser.description()[source]

Return a short description of pyFormex

parser.createParser()[source]

Create a parser for the pyFormex command line.

Returns:

argparse.ArgumentParser – A parser for the pyFormex command line.

parser.parseOptions(args)[source]

Parse command line arguments

The arguments of the pyFormex command line can be splitted in options and remaining arguments. This function will split the options from the other arguments and store them in the variable pf.options for access throughout pyFormex. The remaining arguments are stored in pf.options.args

Parameters:

args (list of str) – A list of command line arguments for the pyformex command

Returns:

bool – True if the parsing was successful.