Package PyFoam :: Package Basics :: Module FoamOptionParser :: Class SubcommandFoamOptionParser
[hide private]
[frames] | no frames]

Class SubcommandFoamOptionParser

source code


Subclass of the regular option parser that allows setting subcommands Inspired by https://gist.github.com/sampsyo/462717

Instance Methods [hide private]
 
__init__(self, args=None, usage=None, version=None, epilog=None, examples=None, description=None, subcommands=[]) source code
 
_subcommand_for_name(self, name)
Return the subcommand in self.subcommands matching the given name.
source code
 
addSubcommand(self, cmd, usage=None) source code
 
format_help(self, formatter=None)
Taken from https://gist.github.com/sampsyo/462717
source code
 
getArgs(self)
Return the arguments left after parsing
source code
 
parse(self, nr=None, exactNr=None)
Do the parsing of a subcommand
source code

Inherited from optparse.OptionParser: add_option_group, check_values, destroy, disable_interspersed_args, enable_interspersed_args, error, exit, expand_prog_name, format_epilog, format_option_help, get_default_values, get_description, get_option_group, get_prog_name, get_usage, get_version, parse_args, print_help, print_usage, print_version, set_default, set_defaults, set_process_default_values, set_usage

Inherited from optparse.OptionParser (private): _add_help_option, _add_version_option, _create_option_list, _get_all_options, _get_args, _get_encoding, _init_parsing_state, _match_long_opt, _populate_option_list, _process_args, _process_long_opt, _process_short_opts

Inherited from optparse.OptionContainer: add_option, add_options, format_description, get_option, has_option, remove_option, set_conflict_handler, set_description

Inherited from optparse.OptionContainer (private): _check_conflict, _create_option_mappings, _share_option_mappings

    Inherited from FoamOptionParser
 
_buildKeyordArgumentList(self)
Go through the lists of options and build a dictionary of keyword arguments (in CamelCase)
source code
 
casePath(self)
Returns the path to the case (if applicable)
source code
 
getApplication(self)
Return the OpenFOAM-Application to be run
source code
 
getOptions(self)
Return the options
source code
 
processKeywordArguments(self, kw) source code
 
restoreEnvironment(self)
Restore the environment to its old glory...
source code
Class Variables [hide private]
  _HelpSubcommand = <PyFoam.Basics.FoamOptionParser.Subcommand o...

Inherited from optparse.OptionParser: standard_option_list

Method Details [hide private]

__init__(self, args=None, usage=None, version=None, epilog=None, examples=None, description=None, subcommands=[])
(Constructor)

source code 
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)
Overrides: optparse.OptionContainer.__init__

_subcommand_for_name(self, name)

source code 

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(self, formatter=None)

source code 

Taken from https://gist.github.com/sampsyo/462717

Overrides: optparse.OptionContainer.format_help

getArgs(self)

source code 

Return the arguments left after parsing

Overrides: FoamOptionParser.getArgs

parse(self, nr=None, exactNr=None)

source code 

Do the parsing of a subcommand

Parameters:
  • nr - minimum number of arguments that are to be passed to the application 3 is default for pre-1.5 versions of OpenFOAM
Overrides: FoamOptionParser.parse

Class Variable Details [hide private]

_HelpSubcommand

Value:
<PyFoam.Basics.FoamOptionParser.Subcommand object at 0x10fb5cdd0>