diff options
| author | Greg Ward <gward@python.net> | 2000-04-21 02:31:07 +0000 |
|---|---|---|
| committer | Greg Ward <gward@python.net> | 2000-04-21 02:31:07 +0000 |
| commit | 56ff5710cb6403a6135fdb2104a3545a27cdff64 (patch) | |
| tree | 0ae9b1cf789b4bb4ac962a3f5b8dd5f0a1cf4d1a /fancy_getopt.py | |
| parent | cae8078a1df69595f030390f134fd59452b6db77 (diff) | |
| download | python-setuptools-git-56ff5710cb6403a6135fdb2104a3545a27cdff64.tar.gz | |
Added 'has_option()', 'get_attr_name()' methods.
Diffstat (limited to 'fancy_getopt.py')
| -rw-r--r-- | fancy_getopt.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/fancy_getopt.py b/fancy_getopt.py index c8112331..cfebab49 100644 --- a/fancy_getopt.py +++ b/fancy_getopt.py @@ -105,6 +105,19 @@ class FancyGetopt: self.option_table.append (option) self.option_index[long_option] = option + + def has_option (self, long_option): + """Return true if the option table for this parser has an + option with long name 'long_option'.""" + return self.option_index.has_key(long_option) + + def get_attr_name (self, long_option): + """Translate long option name 'long_option' to the form it + has as an attribute of some object: ie., translate hyphens + to underscores.""" + return string.translate (long_option, longopt_xlate) + + def set_negative_aliases (self, negative_alias): """Set the negative aliases for this option parser. 'negative_alias' should be a dictionary mapping option names to @@ -183,7 +196,7 @@ class FancyGetopt: ("invalid long option name '%s' " + "(must be letters, numbers, hyphens only") % long - self.attr_name[long] = string.translate (long, longopt_xlate) + self.attr_name[long] = self.get_attr_name (long) if short: self.short_opts.append (short) self.short2long[short[0]] = long |
