PyFoam.Basics.FoamOptionParser module¶
Parse options for the PyFoam-Scripts
-
class
PyFoam.Basics.FoamOptionParser.
FoamHelpFormatter
(indent_increment=0, max_help_position=24, width=None, short_first=0)[source]¶ Bases:
optparse.TitledHelpFormatter
For description and epilog preserve double newlines as one newline
-
__module__
= 'PyFoam.Basics.FoamOptionParser'¶
-
-
class
PyFoam.Basics.FoamOptionParser.
FoamOptionParser
(args=None, usage=None, version=None, description=None, epilog=None, examples=None, interspersed=False)[source]¶ Bases:
optparse.OptionParser
Wrapper to the usual OptionParser to honor the conventions of OpenFOAM-utilities
Options that are not used by the script are passed to the OpenFOAM-application
-
__init__
(args=None, usage=None, version=None, description=None, epilog=None, examples=None, interspersed=False)[source]¶ Parameters: - usage – usage string. If missing a default is used
- version – if missing the PyFoam-version is used
- description – description of the utility
- epilog – Text to be displayed in the help after the options
- examples – Usage examples to be displayed after the epilog
- interspersed – needs to be false if options should be passed to an OpenFOAM-utility
- args – Command line arguments. If unset sys.argv[1:] is used.
Can be a string: it will be splitted then unsing the spaces (very primitive), or a list of strings (prefered)
-
__module__
= 'PyFoam.Basics.FoamOptionParser'¶
-
_buildKeyordArgumentList
()[source]¶ Go through the lists of options and build a dictionary of keyword arguments (in CamelCase)
-
-
class
PyFoam.Basics.FoamOptionParser.
Subcommand
(name, parser=None, help='', aliases=(), nr=None, exactNr=None)[source]¶ Bases:
object
A subcommand of a root command-line application that may be invoked by a SubcommandOptionParser. Taken from https://gist.github.com/sampsyo/462717
-
__dict__
= dict_proxy({'__dict__': <attribute '__dict__' of 'Subcommand' objects>, '__module__': 'PyFoam.Basics.FoamOptionParser', '__weakref__': <attribute '__weakref__' of 'Subcommand' objects>, '__doc__': 'A subcommand of a root command-line application that may be\n invoked by a SubcommandOptionParser.\n Taken from https://gist.github.com/sampsyo/462717\n ', '__init__': <function __init__>})¶
-
__init__
(name, parser=None, help='', aliases=(), nr=None, exactNr=None)[source]¶ Creates a new subcommand. name is the primary way to invoke the subcommand; aliases are alternate names. parser is an OptionParser responsible for parsing the subcommand’s options. help is a short description of the command. If no parser is given, it defaults to a new, empty OptionParser.
-
__module__
= 'PyFoam.Basics.FoamOptionParser'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
PyFoam.Basics.FoamOptionParser.
SubcommandFoamOptionParser
(args=None, usage=None, version=None, epilog=None, examples=None, description=None, subcommands=[])[source]¶ Bases:
PyFoam.Basics.FoamOptionParser.FoamOptionParser
Subclass of the regular option parser that allows setting subcommands Inspired by https://gist.github.com/sampsyo/462717
-
_HelpSubcommand
= <PyFoam.Basics.FoamOptionParser.Subcommand object>¶
-
__init__
(args=None, usage=None, version=None, epilog=None, examples=None, description=None, subcommands=[])[source]¶ Parameters: - usage – usage string. If missing a default is used
- version – if missing the PyFoam-version is used
- description – description of the utility
- subcommands – list with subcommands to prepopulate the parser
- args – Command line arguments. If unset sys.argv[1:] is used.
Can be a string: it will be splitted then unsing the spaces (very primitive), or a list of strings (prefered)
-
__module__
= 'PyFoam.Basics.FoamOptionParser'¶
-
_subcommand_for_name
(name)[source]¶ Return the subcommand in self.subcommands matching the given name. The name may either be the name of a subcommand or an alias. If no subcommand matches, returns None.
-
format_help
(formatter=None)[source]¶ Taken from https://gist.github.com/sampsyo/462717
-