Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions
optparse.OptionGroup Class Reference
Inheritance diagram for optparse.OptionGroup:
Inheritance graph
[legend]
Collaboration diagram for optparse.OptionGroup:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def set_title
def destroy
def format_help
def set_conflict_handler
def set_description
def get_description
def add_option
def add_options
def get_option
def has_option
def remove_option
def format_option_help
def format_description

Public Attributes

 parser
 title
 option_list
 option_class
 defaults
 conflict_handler
 description

Private Member Functions

def _create_option_list

Detailed Description

Definition at line 1077 of file optparse.py.


Constructor & Destructor Documentation

def optparse.OptionGroup.__init__ (   self,
  parser,
  title,
  description = None 
)

Reimplemented from optparse.OptionContainer.

Definition at line 1079 of file optparse.py.

01079 
01080     def __init__(self, parser, title, description=None):
01081         self.parser = parser
01082         OptionContainer.__init__(
01083             self, parser.option_class, parser.conflict_handler, description)
01084         self.title = title

Here is the caller graph for this function:


Member Function Documentation

def optparse.OptionGroup._create_option_list (   self) [private]

Definition at line 1085 of file optparse.py.

01085 
01086     def _create_option_list(self):
01087         self.option_list = []
01088         self._share_option_mappings(self.parser)

Here is the caller graph for this function:

def optparse.OptionContainer.add_option (   self,
  args,
  kwargs 
) [inherited]
add_option(Option)
   add_option(opt_str, ..., kwarg=val, ...)

Definition at line 996 of file optparse.py.

00996 
00997     def add_option(self, *args, **kwargs):
00998         """add_option(Option)
00999            add_option(opt_str, ..., kwarg=val, ...)
01000         """
01001         if isinstance(args[0], str):
01002             option = self.option_class(*args, **kwargs)
01003         elif len(args) == 1 and not kwargs:
01004             option = args[0]
01005             if not isinstance(option, Option):
01006                 raise TypeError("not an Option instance: %r" % option)
01007         else:
01008             raise TypeError("invalid arguments")
01009 
01010         self._check_conflict(option)
01011 
01012         self.option_list.append(option)
01013         option.container = self
01014         for opt in option._short_opts:
01015             self._short_opt[opt] = option
01016         for opt in option._long_opts:
01017             self._long_opt[opt] = option
01018 
01019         if option.dest is not None:     # option has a dest, we need a default
01020             if option.default is not NO_DEFAULT:
01021                 self.defaults[option.dest] = option.default
01022             elif option.dest not in self.defaults:
01023                 self.defaults[option.dest] = None
01024 
01025         return option

Here is the call graph for this function:

Here is the caller graph for this function:

def optparse.OptionContainer.add_options (   self,
  option_list 
) [inherited]

Definition at line 1026 of file optparse.py.

01026 
01027     def add_options(self, option_list):
01028         for option in option_list:
01029             self.add_option(option)

Here is the call graph for this function:

Here is the caller graph for this function:

see OptionParser.destroy().

Reimplemented from optparse.OptionContainer.

Definition at line 1092 of file optparse.py.

01092 
01093     def destroy(self):
01094         """see OptionParser.destroy()."""
01095         OptionContainer.destroy(self)
01096         del self.option_list

Here is the caller graph for this function:

def optparse.OptionContainer.format_description (   self,
  formatter 
) [inherited]

Definition at line 1065 of file optparse.py.

01065 
01066     def format_description(self, formatter):
01067         return formatter.format_description(self.get_description())

Here is the call graph for this function:

Here is the caller graph for this function:

def optparse.OptionGroup.format_help (   self,
  formatter 
)

Reimplemented from optparse.OptionContainer.

Definition at line 1099 of file optparse.py.

01099 
01100     def format_help(self, formatter):
01101         result = formatter.format_heading(self.title)
01102         formatter.indent()
01103         result += OptionContainer.format_help(self, formatter)
01104         formatter.dedent()
01105         return result
01106 

def optparse.OptionContainer.format_option_help (   self,
  formatter 
) [inherited]

Reimplemented in optparse.OptionParser.

Definition at line 1056 of file optparse.py.

01056 
01057     def format_option_help(self, formatter):
01058         if not self.option_list:
01059             return ""
01060         result = []
01061         for option in self.option_list:
01062             if not option.help is SUPPRESS_HELP:
01063                 result.append(formatter.format_option(option))
01064         return "".join(result)

Here is the caller graph for this function:

def optparse.OptionContainer.get_description (   self) [inherited]

Reimplemented in optparse.OptionParser.

Definition at line 956 of file optparse.py.

00956 
00957     def get_description(self):
00958         return self.description
00959 

Here is the caller graph for this function:

def optparse.OptionContainer.get_option (   self,
  opt_str 
) [inherited]

Definition at line 1032 of file optparse.py.

01032 
01033     def get_option(self, opt_str):
01034         return (self._short_opt.get(opt_str) or
01035                 self._long_opt.get(opt_str))

def optparse.OptionContainer.has_option (   self,
  opt_str 
) [inherited]

Definition at line 1036 of file optparse.py.

01036 
01037     def has_option(self, opt_str):
01038         return (opt_str in self._short_opt or
01039                 opt_str in self._long_opt)

def optparse.OptionContainer.remove_option (   self,
  opt_str 
) [inherited]

Definition at line 1040 of file optparse.py.

01040 
01041     def remove_option(self, opt_str):
01042         option = self._short_opt.get(opt_str)
01043         if option is None:
01044             option = self._long_opt.get(opt_str)
01045         if option is None:
01046             raise ValueError("no such option %r" % opt_str)
01047 
01048         for opt in option._short_opts:
01049             del self._short_opt[opt]
01050         for opt in option._long_opts:
01051             del self._long_opt[opt]
01052         option.container.option_list.remove(option)
01053 

def optparse.OptionContainer.set_conflict_handler (   self,
  handler 
) [inherited]

Definition at line 948 of file optparse.py.

00948 
00949     def set_conflict_handler(self, handler):
00950         if handler not in ("error", "resolve"):
00951             raise ValueError("invalid conflict_resolution value %r" % handler)
00952         self.conflict_handler = handler

def optparse.OptionContainer.set_description (   self,
  description 
) [inherited]

Definition at line 953 of file optparse.py.

00953 
00954     def set_description(self, description):
00955         self.description = description

def optparse.OptionGroup.set_title (   self,
  title 
)

Definition at line 1089 of file optparse.py.

01089 
01090     def set_title(self, title):
01091         self.title = title


Member Data Documentation

Definition at line 951 of file optparse.py.

Definition at line 938 of file optparse.py.

Definition at line 954 of file optparse.py.

Definition at line 928 of file optparse.py.

Definition at line 1086 of file optparse.py.

Definition at line 1080 of file optparse.py.

Definition at line 1083 of file optparse.py.


The documentation for this class was generated from the following file: