summaryrefslogtreecommitdiffstats
path: root/Lib/distutils
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2000-04-21 02:31:07 (GMT)
committerGreg Ward <gward@python.net>2000-04-21 02:31:07 (GMT)
commit320df700dc296e1acab363d7537bb32fd6b05394 (patch)
treef8355ddf1f18a66581be45e38457ef533571eb5e /Lib/distutils
parent82715e1f11ec1f4c7b13b07ca55f56850c4c3dab (diff)
downloadcpython-320df700dc296e1acab363d7537bb32fd6b05394.zip
cpython-320df700dc296e1acab363d7537bb32fd6b05394.tar.gz
cpython-320df700dc296e1acab363d7537bb32fd6b05394.tar.bz2
Added 'has_option()', 'get_attr_name()' methods.
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/fancy_getopt.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/distutils/fancy_getopt.py b/Lib/distutils/fancy_getopt.py
index c811233..cfebab4 100644
--- a/Lib/distutils/fancy_getopt.py
+++ b/Lib/distutils/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