massive import cleaning in Distutils
diff --git a/Lib/distutils/fancy_getopt.py b/Lib/distutils/fancy_getopt.py
index e19319a..2dea948 100644
--- a/Lib/distutils/fancy_getopt.py
+++ b/Lib/distutils/fancy_getopt.py
@@ -10,10 +10,11 @@
__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 @@
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 @@
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 @@
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 @@
'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