diff options
Diffstat (limited to 'Lib/distutils/fancy_getopt.py')
-rw-r--r-- | Lib/distutils/fancy_getopt.py | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/Lib/distutils/fancy_getopt.py b/Lib/distutils/fancy_getopt.py index e19319ae9d..2dea948025 100644 --- a/Lib/distutils/fancy_getopt.py +++ b/Lib/distutils/fancy_getopt.py @@ -10,10 +10,11 @@ additional features: __revision__ = "$Id$" -import sys, string, re -from types import * +import sys +import string +import re import getopt -from distutils.errors import * +from distutils.errors import DistutilsGetoptError, DistutilsArgError # Much like command_re in distutils.core, this is close to but not quite # the same as a Python NAME -- except, in the spirit of most GNU @@ -117,7 +118,7 @@ class FancyGetopt: def _check_alias_dict (self, aliases, what): - assert type(aliases) is DictionaryType + assert isinstance(aliases, dict) for (alias, opt) in aliases.items(): if alias not in self.option_index: raise DistutilsGetoptError, \ @@ -164,13 +165,13 @@ class FancyGetopt: raise ValueError, "invalid option tuple: %r" % (option,) # Type- and value-check the option names - if type(long) is not StringType or len(long) < 2: + if not isinstance(long, str) or len(long) < 2: raise DistutilsGetoptError, \ ("invalid long option '%s': " "must be a string of length >= 2") % long if (not ((short is None) or - (type(short) is StringType and len(short) == 1))): + (isinstance(short, str) and len(short) == 1))): raise DistutilsGetoptError, \ ("invalid short option '%s': " "must a single character or None") % short @@ -464,10 +465,8 @@ def wrap_text (text, width): return lines -# wrap_text () - -def translate_longopt (opt): +def translate_longopt(opt): """Convert a long option name to a valid Python identifier by changing "-" to "_". """ @@ -483,18 +482,3 @@ class OptionDummy: 'options' will be initialized to None.""" for opt in options: setattr(self, opt, None) - -# class OptionDummy - - -if __name__ == "__main__": - text = """\ -Tra-la-la, supercalifragilisticexpialidocious. -How *do* you spell that odd word, anyways? -(Someone ask Mary -- she'll know [or she'll -say, "How should I know?"].)""" - - for w in (10, 20, 30, 40): - print "width: %d" % w - print string.join(wrap_text(text, w), "\n") - print |