summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/fancy_getopt.py
diff options
context:
space:
mode:
authorTarek Ziadé <ziade.tarek@gmail.com>2009-12-21 01:22:46 (GMT)
committerTarek Ziadé <ziade.tarek@gmail.com>2009-12-21 01:22:46 (GMT)
commit2b66da7d15e47f9ca0d08d4f18fc63c3ee6a0d51 (patch)
tree5f601e8659a1511fc64880c935d1033318b9cccf /Lib/distutils/fancy_getopt.py
parent2421d56e0205b58b925d1b6534f8ee3505ed549b (diff)
downloadcpython-2b66da7d15e47f9ca0d08d4f18fc63c3ee6a0d51.zip
cpython-2b66da7d15e47f9ca0d08d4f18fc63c3ee6a0d51.tar.gz
cpython-2b66da7d15e47f9ca0d08d4f18fc63c3ee6a0d51.tar.bz2
massive import cleaning in Distutils
Diffstat (limited to 'Lib/distutils/fancy_getopt.py')
-rw-r--r--Lib/distutils/fancy_getopt.py32
1 files changed, 8 insertions, 24 deletions
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 @@ 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