Changeset 320

Show
Ignore:
Timestamp:
Tue Nov 6 02:26:59 2007
Author:
giovannibajo
Message:

Make optparse/optik use native line endings.

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/optparse.py

    r109 r320  
    1   """  
    2   optparse -- forward-compatibility wrapper for use with Python 2.2.x and  
    3   earlier.  If you import from 'optparse' rather than 'optik', your code  
    4   will work on base Python 2.3 (and later), or on earlier Pythons with  
    5   Optik 1.4.1 or later installed.  
    6   """  
    7    
    8   from optik import __version__, __all__  
    9   from optik import *  
      1 """  
      2 optparse -- forward-compatibility wrapper for use with Python 2.2.x and  
      3 earlier.  If you import from 'optparse' rather than 'optik', your code  
      4 will work on base Python 2.3 (and later), or on earlier Pythons with  
      5 Optik 1.4.1 or later installed.  
      6 """  
      7  
      8 from optik import __version__, __all__  
      9 from optik import *  
  • trunk/optik/help.py

    r112 r320  
    1   """optik.help  
    2    
    3   Provides HelpFormatter and subclasses -- used by OptionParser  
    4   to generate formatted help text.  
    5   """  
    6    
    7   # Copyright (c) 2001-2004 Gregory P. Ward.  All rights reserved.  
    8   # See the README.txt distributed with Optik for licensing terms.  
    9    
    10   import os  
    11   import string  
    12   import textwrap  
    13   from optik.option import NO_DEFAULT  
    14   from optik.errors import gettext  
    15   _ = gettext  
    16    
    17   __revision__ = "$Id: help.py 470 2004-12-07 01:39:56Z gward $"  
    18    
    19   __all__ = ['HelpFormatter', 'IndentedHelpFormatter', 'TitledHelpFormatter']  
    20    
    21   class HelpFormatter:  
    22    
    23       """  
    24       Abstract base class for formatting option help.  OptionParser  
    25       instances should use one of the HelpFormatter subclasses for  
    26       formatting help; by default IndentedHelpFormatter is used.  
    27    
    28       Instance attributes:  
    29         parser : OptionParser  
    30           the controlling OptionParser instance  
    31         indent_increment : int  
    32           the number of columns to indent per nesting level  
    33         max_help_position : int  
    34           the maximum starting column for option help text  
    35         help_position : int  
    36           the calculated starting column for option help text;  
    37           initially the same as the maximum  
    38         width : int  
    39           total number of columns for output (pass None to constructor for  
    40           this value to be taken from the $COLUMNS environment variable)  
    41         level : int  
    42           current indentation level  
    43         current_indent : int  
    44           current indentation level (in columns)  
    45         help_width : int  
    46           number of columns available for option help text (calculated)  
    47         default_tag : str  
    48           text to replace with each option's default value, "%default"  
    49           by default.  Set to false value to disable default value expansion.  
    50         option_strings : { Option : str }  
    51           maps Option instances to the snippet of help text explaining  
    52           the syntax of that option, e.g. "-h, --help" or  
    53           "-fFILE, --file=FILE"  
    54         _short_opt_fmt : str  
    55           format string controlling how short options with values are  
    56           printed in help text.  Must be either "%s%s" ("-fFILE") or  
    57           "%s %s" ("-f FILE"), because those are the two syntaxes that  
    58           Optik supports.  
    59         _long_opt_fmt : str  
    60           similar but for long options; must be either "%s %s" ("--file FILE")  
    61           or "%s=%s" ("--file=FILE").  
    62       """  
    63    
    64       NO_DEFAULT_VALUE = "none"  
    65    
    66       def __init__(self,  
    67                    indent_increment,  
    68                    max_help_position,  
    69                    width,  
    70                    short_first):  
    71           self.parser = None  
    72           self.indent_increment = indent_increment  
    73           self.help_position = self.max_help_position = max_help_position  
    74           if width is None:  
    75               try:  
    76                   width = int(os.environ['COLUMNS'])  
    77               except (KeyError, ValueError):  
    78                   width = 80  
    79               width = width - 2  
    80           self.width = width  
    81           self.current_indent = 0  
    82           self.level = 0  
    83           self.help_width = None          # computed later  
    84           self.short_first = short_first  
    85           self.default_tag = "%default"  
    86           self.option_strings = {}  
    87           self._short_opt_fmt = "%s %s"  
    88           self._long_opt_fmt = "%s=%s"  
    89    
    90       def set_parser(self, parser):  
    91           self.parser = parser  
    92    
    93       def set_short_opt_delimiter(self, delim):  
    94           if delim not in ("", " "):  
    95               raise ValueError(  
    96                   "invalid metavar delimiter for short options: %r" % delim)  
    97           self._short_opt_fmt = "%s" + delim + "%s"  
    98    
    99       def set_long_opt_delimiter(self, delim):  
    100           if delim not in ("=", " "):  
    101               raise ValueError(  
    102                   "invalid metavar delimiter for long options: %r" % delim)  
    103           self._long_opt_fmt = "%s" + delim + "%s"  
    104    
    105       def indent(self):  
    106           self.current_indent = self.current_indent + self.indent_increment  
    107           self.level = self.level + 1  
    108    
    109       def dedent(self):  
    110           self.current_indent = self.current_indent - self.indent_increment  
    111           assert self.current_indent >= 0, "Indent decreased below 0."  
    112           self.level = self.level - 1  
    113    
    114       def format_usage(self, usage):  
    115           raise NotImplementedError, "subclasses must implement"  
    116    
    117       def format_heading(self, heading):  
    118           raise NotImplementedError, "subclasses must implement"  
    119    
    120       def format_description(self, description):  
    121           if not description:  
    122               return ""  
    123           desc_width = self.width - self.current_indent  
    124           indent = " "*self.current_indent  
    125           return textwrap.fill(description,  
    126                                desc_width,  
    127                                initial_indent=indent,  
    128                                subsequent_indent=indent) + "\n"  
    129    
    130       def expand_default(self, option):  
    131           if self.parser is None or not self.default_tag:  
    132               return option.help  
    133    
    134           default_value = self.parser.defaults.get(option.dest)  
    135           if default_value is NO_DEFAULT or default_value is None:  
    136               default_value = self.NO_DEFAULT_VALUE  
    137    
    138           return string.replace(option.help, self.default_tag, str(default_value))  
    139    
    140       def format_option(self, option):  
    141           # The help for each option consists of two parts:  
    142           #   * the opt strings and metavars  
    143           #     eg. ("-x", or "-fFILENAME, --file=FILENAME")  
    144           #   * the user-supplied help string  
    145           #     eg. ("turn on expert mode", "read data from FILENAME")  
    146           #  
    147           # If possible, we write both of these on the same line:  
    148           #   -x      turn on expert mode  
    149           #  
    150           # But if the opt string list is too long, we put the help  
    151           # string on a second line, indented to the same column it would  
    152           # start in if it fit on the first line.  
    153           #   -fFILENAME, --file=FILENAME  
    154           #           read data from FILENAME  
    155           result = []  
    156           opts = self.option_strings[option]  
    157           opt_width = self.help_position - self.current_indent - 2  
    158           if len(opts) > opt_width:  
    159               opts = "%*s%s\n" % (self.current_indent, "", opts)  
    160               indent_first = self.help_position  
    161           else:                       # start help on same line as opts  
    162               opts = "%*s%-*s  " % (self.current_indent, "", opt_width, opts)  
    163               indent_first = 0  
    164           result.append(opts)  
    165           if option.help:  
    166               help_text = self.expand_default(option)  
    167               help_lines = textwrap.wrap(help_text, self.help_width)  
    168               result.append("%*s%s\n" % (indent_first, "", help_lines[0]))  
    169               for line in help_lines[1:]:  
    170                   result.append("%*s%s\n" % (self.help_position, "", line))  
    171           elif opts[-1] != "\n":  
    172               result.append("\n")  
    173           return string.join(result, "")  
    174    
    175       def store_option_strings(self, parser):  
    176           self.indent()  
    177           max_len = 0  
    178           for opt in parser.option_list:  
    179               strings = self.format_option_strings(opt)  
    180               self.option_strings[opt] = strings  
    181               max_len = max(max_len, len(strings) + self.current_indent)  
    182           self.indent()  
    183           for group in parser.option_groups:  
    184               for opt in group.option_list:  
    185                   strings = self.format_option_strings(opt)  
    186                   self.option_strings[opt] = strings  
    187                   max_len = max(max_len, len(strings) + self.current_indent)  
    188           self.dedent()  
    189           self.dedent()  
    190           self.help_position = min(max_len + 2, self.max_help_position)  
    191           self.help_width = self.width - self.help_position  
    192    
    193       def format_option_strings(self, option):  
    194           """Return a comma-separated list of option strings & metavariables."""  
    195           if option.takes_value():  
    196               metavar = option.metavar or string.upper(option.dest)  
    197               short_opts = []  
    198               for sopt in option._short_opts:  
    199                   short_opts.append(self._short_opt_fmt % (sopt, metavar))  
    200               long_opts = []  
    201               for lopt in option._long_opts:  
    202                   long_opts.append(self._long_opt_fmt % (lopt, metavar))  
    203           else:  
    204               short_opts = option._short_opts  
    205               long_opts = option._long_opts  
    206    
    207           if self.short_first:  
    208               opts = short_opts + long_opts  
    209           else:  
    210               opts = long_opts + short_opts  
    211    
    212           return string.join(opts, ", ")  
    213    
    214   class IndentedHelpFormatter (HelpFormatter):  
    215       """Format help with indented section bodies.  
    216       """  
    217    
    218       def __init__(self,  
    219                    indent_increment=2,  
    220                    max_help_position=24,  
    221                    width=None,  
    222                    short_first=1):  
    223           HelpFormatter.__init__(  
    224               self, indent_increment, max_help_position, width, short_first)  
    225    
    226       def format_usage(self, usage):  
    227           return _("usage: %s\n") % usage  
    228    
    229       def format_heading(self, heading):  
    230           return "%*s%s:\n" % (self.current_indent, "", heading)  
    231    
    232    
    233   class TitledHelpFormatter (HelpFormatter):  
    234       """Format help with underlined section headers.  
    235       """  
    236    
    237       def __init__(self,  
    238                    indent_increment=0,  
    239                    max_help_position=24,  
    240                    width=None,  
    241                    short_first=0):  
    242           HelpFormatter.__init__ (  
    243               self, indent_increment, max_help_position, width, short_first)  
    244    
    245       def format_usage(self, usage):  
    246           return "%s  %s\n" % (self.format_heading(_("Usage")), usage)  
    247    
    248       def format_heading(self, heading):  
    249           return "%s\n%s\n" % (heading, "=-"[self.level] * len(heading))  
      1 """optik.help  
      2  
      3 Provides HelpFormatter and subclasses -- used by OptionParser  
      4 to generate formatted help text.  
      5 """  
      6  
      7 # Copyright (c) 2001-2004 Gregory P. Ward.  All rights reserved.  
      8 # See the README.txt distributed with Optik for licensing terms.  
      9  
      10 import os  
      11 import string  
      12 import textwrap  
      13 from optik.option import NO_DEFAULT  
      14 from optik.errors import gettext  
      15 _ = gettext  
      16  
      17 __revision__ = "$Id: help.py 470 2004-12-07 01:39:56Z gward $"  
      18  
      19 __all__ = ['HelpFormatter', 'IndentedHelpFormatter', 'TitledHelpFormatter']  
      20  
      21 class HelpFormatter:  
      22  
      23     """  
      24     Abstract base class for formatting option help.  OptionParser  
      25     instances should use one of the HelpFormatter subclasses for  
      26     formatting help; by default IndentedHelpFormatter is used.  
      27  
      28     Instance attributes:  
      29       parser : OptionParser  
      30         the controlling OptionParser instance  
      31       indent_increment : int  
      32         the number of columns to indent per nesting level  
      33       max_help_position : int  
      34         the maximum starting column for option help text  
      35       help_position : int  
      36         the calculated starting column for option help text;  
      37         initially the same as the maximum  
      38       width : int  
      39         total number of columns for output (pass None to constructor for  
      40         this value to be taken from the $COLUMNS environment variable)  
      41       level : int  
      42         current indentation level  
      43       current_indent : int  
      44         current indentation level (in columns)  
      45       help_width : int  
      46         number of columns available for option help text (calculated)  
      47       default_tag : str  
      48         text to replace with each option's default value, "%default"  
      49         by default.  Set to false value to disable default value expansion.  
      50       option_strings : { Option : str }  
      51         maps Option instances to the snippet of help text explaining  
      52         the syntax of that option, e.g. "-h, --help" or  
      53         "-fFILE, --file=FILE"  
      54       _short_opt_fmt : str  
      55         format string controlling how short options with values are  
      56         printed in help text.  Must be either "%s%s" ("-fFILE") or  
      57         "%s %s" ("-f FILE"), because those are the two syntaxes that  
      58         Optik supports.  
      59       _long_opt_fmt : str  
      60         similar but for long options; must be either "%s %s" ("--file FILE")  
      61         or "%s=%s" ("--file=FILE").  
      62     """  
      63  
      64     NO_DEFAULT_VALUE = "none"  
      65  
      66     def __init__(self,  
      67                  indent_increment,  
      68                  max_help_position,  
      69                  width,  
      70                  short_first):  
      71         self.parser = None  
      72         self.indent_increment = indent_increment  
      73         self.help_position = self.max_help_position = max_help_position  
      74         if width is None:  
      75             try:  
      76                 width = int(os.environ['COLUMNS'])  
      77             except (KeyError, ValueError):  
      78                 width = 80  
      79             width = width - 2  
      80         self.width = width  
      81         self.current_indent = 0  
      82         self.level = 0  
      83         self.help_width = None          # computed later  
      84         self.short_first = short_first  
      85         self.default_tag = "%default"  
      86         self.option_strings = {}  
      87         self._short_opt_fmt = "%s %s"  
      88         self._long_opt_fmt = "%s=%s"  
      89  
      90     def set_parser(self, parser):  
      91         self.parser = parser  
      92  
      93     def set_short_opt_delimiter(self, delim):  
      94         if delim not in ("", " "):  
      95             raise ValueError(  
      96                 "invalid metavar delimiter for short options: %r" % delim)  
      97         self._short_opt_fmt = "%s" + delim + "%s"  
      98  
      99     def set_long_opt_delimiter(self, delim):  
      100         if delim not in ("=", " "):  
      101             raise ValueError(  
      102                 "invalid metavar delimiter for long options: %r" % delim)  
      103         self._long_opt_fmt = "%s" + delim + "%s"  
      104  
      105     def indent(self):  
      106         self.current_indent = self.current_indent + self.indent_increment  
      107         self.level = self.level + 1  
      108  
      109     def dedent(self):  
      110         self.current_indent = self.current_indent - self.indent_increment  
      111         assert self.current_indent >= 0, "Indent decreased below 0."  
      112         self.level = self.level - 1  
      113  
      114     def format_usage(self, usage):  
      115         raise NotImplementedError, "subclasses must implement"  
      116  
      117     def format_heading(self, heading):  
      118         raise NotImplementedError, "subclasses must implement"  
      119  
      120     def format_description(self, description):  
      121         if not description:  
      122             return ""  
      123         desc_width = self.width - self.current_indent  
      124         indent = " "*self.current_indent  
      125         return textwrap.fill(description,  
      126                              desc_width,  
      127                              initial_indent=indent,  
      128                              subsequent_indent=indent) + "\n"  
      129  
      130     def expand_default(self, option):  
      131         if self.parser is None or not self.default_tag:  
      132             return option.help  
      133  
      134         default_value = self.parser.defaults.get(option.dest)  
      135         if default_value is NO_DEFAULT or default_value is None:  
      136             default_value = self.NO_DEFAULT_VALUE  
      137  
      138         return string.replace(option.help, self.default_tag, str(default_value))  
      139  
      140     def format_option(self, option):  
      141         # The help for each option consists of two parts:  
      142         #   * the opt strings and metavars  
      143         #     eg. ("-x", or "-fFILENAME, --file=FILENAME")  
      144         #   * the user-supplied help string  
      145         #     eg. ("turn on expert mode", "read data from FILENAME")  
      146         #  
      147         # If possible, we write both of these on the same line:  
      148         #   -x      turn on expert mode  
      149         #  
      150         # But if the opt string list is too long, we put the help  
      151         # string on a second line, indented to the same column it would  
      152         # start in if it fit on the first line.  
      153         #   -fFILENAME, --file=FILENAME  
      154         #           read data from FILENAME  
      155         result = []  
      156         opts = self.option_strings[option]  
      157         opt_width = self.help_position - self.current_indent - 2  
      158         if len(opts) > opt_width:  
      159             opts = "%*s%s\n" % (self.current_indent, "", opts)  
      160             indent_first = self.help_position  
      161         else:                       # start help on same line as opts  
      162             opts = "%*s%-*s  " % (self.current_indent, "", opt_width, opts)  
      163             indent_first = 0  
      164         result.append(opts)  
      165         if option.help:  
      166             help_text = self.expand_default(option)  
      167             help_lines = textwrap.wrap(help_text, self.help_width)  
      168             result.append("%*s%s\n" % (indent_first, "", help_lines[0]))  
      169             for line in help_lines[1:]:  
      170                 result.append("%*s%s\n" % (self.help_position, "", line))  
      171         elif opts[-1] != "\n":  
      172             result.append("\n")  
      173         return string.join(result, "")  
      174  
      175     def store_option_strings(self, parser):  
      176         self.indent()  
      177         max_len = 0  
      178         for opt in parser.option_list:  
      179             strings = self.format_option_strings(opt)  
      180             self.option_strings[opt] = strings  
      181             max_len = max(max_len, len(strings) + self.current_indent)  
      182         self.indent()  
      183         for group in parser.option_groups:  
      184             for opt in group.option_list:  
      185                 strings = self.format_option_strings(opt)  
      186                 self.option_strings[opt] = strings  
      187                 max_len = max(max_len, len(strings) + self.current_indent)  
      188         self.dedent()  
      189         self.dedent()  
      190         self.help_position = min(max_len + 2, self.max_help_position)  
      191         self.help_width = self.width - self.help_position  
      192  
      193     def format_option_strings(self, option):  
      194         """Return a comma-separated list of option strings & metavariables."""  
      195         if option.takes_value():  
      196             metavar = option.metavar or string.upper(option.dest)  
      197             short_opts = []  
      198             for sopt in option._short_opts:  
      199                 short_opts.append(self._short_opt_fmt % (sopt, metavar))  
      200             long_opts = []  
      201             for lopt in option._long_opts:  
      202                 long_opts.append(self._long_opt_fmt % (lopt, metavar))  
      203         else:  
      204             short_opts = option._short_opts  
      205             long_opts = option._long_opts  
      206  
      207         if self.short_first:  
      208             opts = short_opts + long_opts  
      209         else:  
      210             opts = long_opts + short_opts  
      211  
      212         return string.join(opts, ", ")  
      213  
      214 class IndentedHelpFormatter (HelpFormatter):  
      215     """Format help with indented section bodies.  
      216     """  
      217  
      218     def __init__(self,  
      219                  indent_increment=2,  
      220                  max_help_position=24,  
      221                  width=None,  
      222                  short_first=1):  
      223         HelpFormatter.__init__(  
      224             self, indent_increment, max_help_position, width, short_first)  
      225  
      226     def format_usage(self, usage):  
      227         return _("usage: %s\n") % usage  
      228  
      229     def format_heading(self, heading):  
      230         return "%*s%s:\n" % (self.current_indent, "", heading)  
      231  
      232  
      233 class TitledHelpFormatter (HelpFormatter):  
      234     """Format help with underlined section headers.  
      235     """  
      236  
      237     def __init__(self,  
      238                  indent_increment=0,  
      239                  max_help_position=24,  
      240                  width=None,  
      241                  short_first=0):  
      242         HelpFormatter.__init__ (  
      243             self, indent_increment, max_help_position, width, short_first)  
      244  
      245     def format_usage(self, usage):  
      246         return "%s  %s\n" % (self.format_heading(_("Usage")), usage)  
      247  
      248     def format_heading(self, heading):  
      249         return "%s\n%s\n" % (heading, "=-"[self.level] * len(heading))  
  • trunk/optik/option.py

    r112 r320  
    1   """optik.option  
    2    
    3   Defines the Option class and some standard value-checking functions.  
    4   """  
    5    
    6   # Copyright (c) 2001-2004 Gregory P. Ward.  All rights reserved.  
    7   # See the README.txt distributed with Optik for licensing terms.  
    8    
    9   import sys  
    10   import types, string  
    11   from optik.errors import OptionError, OptionValueError, gettext  
    12   _ = gettext  
    13    
    14   __revision__ = "$Id: option.py 470 2004-12-07 01:39:56Z gward $"  
    15    
    16   __all__ = ['Option']  
    17    
    18   # Do the right thing with boolean values for all known Python versions.  
    19   try:  
    20       True, False  
    21   except NameError:  
    22       (True, False) = (1, 0)  
    23    
    24   # For Python 1.5, just ignore unicode (try it as str)  
    25   try:  
    26       unicode  
    27   except NameError:  
    28       unicode=str  
    29   try:  
    30       types.UnicodeType  
    31   except AttributeError:  
    32       types.UnicodeType = types.StringType  
    33    
    34   _idmax = 2L * sys.maxint + 1  
    35    
    36   def _repr(self):  
    37       return "<%s at 0x%x: %s>" % (self.__class__.__name__,  
    38                                    id(self) & _idmax,  
    39                                    self)  
    40    
    41   def _parse_num(val, type):  
    42       if string.lower(val[:2]) == "0x":   # hexadecimal  
    43           radix = 16  
    44       elif string.lower(val[:2]) == "0b": # binary  
    45           radix = 2  
    46           val = val[2:] or "0"            # have to remove "0b" prefix  
    47       elif val[:1] == "0":                # octal  
    48           radix = 8  
    49       else:                               # decimal  
    50           radix = 10  
    51    
    52       try:  
    53           return type(val, radix)  
    54       except TypeError:  
    55           # In Python pre-2.0, int() and long() did not support the radix  
    56           # argument. We catch the type error (not to be confused with ValueError,  
    57           # which is a real parsing failure), and try again with string.atol.  
    58           return type(string.atol(val, radix))  
    59    
    60   def _parse_int(val):  
    61       return _parse_num(val, int)  
    62    
    63   def _parse_long(val):  
    64       return _parse_num(val, long)  
    65    
    66   _builtin_cvt = { "int" : (_parse_int, _("integer")),  
    67                    "long" : (_parse_long, _("long integer")),  
    68                    "float" : (float, _("floating-point")),  
    69                    "complex" : (complex, _("complex")) }  
    70    
    71   def check_builtin(option, opt, value):  
    72       (cvt, what) = _builtin_cvt[option.type]  
    73       try:  
    74           return cvt(value)  
    75       except ValueError:  
    76           raise OptionValueError(  
    77               _("option %s: invalid %s value: %s") % (opt, what, repr(value)))  
    78    
    79   def check_choice(option, opt, value):  
    80       if value in option.choices:  
    81           return value  
    82       else:  
    83           choices = string.join(map(repr, option.choices), ", ")  
    84           raise OptionValueError(  
    85               _("option %s: invalid choice: %s (choose from %s)")  
    86               % (opt, repr(value), choices))  
    87    
    88   # Not supplying a default is different from a default of None,  
    89   # so we need an explicit "not supplied" value.  
    90   NO_DEFAULT = ("NO", "DEFAULT")  
    91    
    92    
    93   class Option:  
    94       """  
    95       Instance attributes:  
    96         _short_opts : [string]  
    97         _long_opts : [string]  
    98    
    99         action : string  
    100         type : string  
    101         dest : string  
    102         default : any  
    103         nargs : int  
    104         const : any  
    105         choices : [string]  
    106         callback : function  
    107         callback_args : (any*)  
    108         callback_kwargs : { string : any }  
    109         help : string  
    110         metavar : string  
    111       """  
    112    
    113       # The list of instance attributes that may be set through  
    114       # keyword args to the constructor.  
    115       ATTRS = ['action',  
    116                'type',  
    117                'dest',  
    118                'default',  
    119                'nargs',  
    120                'const',  
    121                'choices',  
    122                'callback',  
    123                'callback_args',  
    124                'callback_kwargs',  
    125                'help',  
    126                'metavar']  
    127    
    128       # The set of actions allowed by option parsers.  Explicitly listed  
    129       # here so the constructor can validate its arguments.  
    130       ACTIONS = ("store",  
    131                  "store_const",  
    132                  "store_true",  
    133                  "store_false",  
    134                  "append",  
    135                  "append_const",  
    136                  "count",  
    137                  "callback",  
    138                  "help",  
    139                  "version")  
    140    
    141       # The set of actions that involve storing a value somewhere;  
    142       # also listed just for constructor argument validation.  (If  
    143       # the action is one of these, there must be a destination.)  
    144       STORE_ACTIONS = ("store",  
    145                        "store_const",  
    146                        "store_true",  
    147                        "store_false",  
    148                        "append",  
    149                        "append_const",  
    150                        "count")  
    151    
    152       # The set of actions for which it makes sense to supply a value  
    153       # type, ie. which may consume an argument from the command line.  
    154       TYPED_ACTIONS = ("store",  
    155                        "append",  
    156                        "callback")  
    157    
    158       # The set of actions which *require* a value type, ie. that  
    159       # always consume an argument from the command line.  
    160       ALWAYS_TYPED_ACTIONS = ("store",  
    161                               "append")  
    162    
    163       # The set of actions which take a 'const' attribute.  
    164       CONST_ACTIONS = ("store_const",  
    165                        "append_const")  
    166    
    167       # The set of known types for option parsers.  Again, listed here for  
    168       # constructor argument validation.  
    169       TYPES = ("string", "int", "long", "float", "complex", "choice")  
    170    
    171       # Dictionary of argument checking functions, which convert and  
    172       # validate option arguments according to the option type.  
    173       #  
    174       # Signature of checking functions is:  </