Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/distutils/fancy_getopt.py

    r2 r391  
    99"""
    1010
    11 # This module should be kept compatible with Python 2.1.
    12 
    13 __revision__ = "$Id: fancy_getopt.py 60923 2008-02-21 18:18:37Z guido.van.rossum $"
    14 
    15 import sys, string, re
    16 from types import *
     11__revision__ = "$Id$"
     12
     13import sys
     14import string
     15import re
    1716import getopt
    18 from distutils.errors import *
     17from distutils.errors import DistutilsGetoptError, DistutilsArgError
    1918
    2019# Much like command_re in distutils.core, this is close to but not quite
     
    120119
    121120    def _check_alias_dict (self, aliases, what):
    122         assert type(aliases) is DictionaryType
     121        assert isinstance(aliases, dict)
    123122        for (alias, opt) in aliases.items():
    124123            if alias not in self.option_index:
     
    167166
    168167            # Type- and value-check the option names
    169             if type(long) is not StringType or len(long) < 2:
     168            if not isinstance(long, str) or len(long) < 2:
    170169                raise DistutilsGetoptError, \
    171170                      ("invalid long option '%s': "
     
    173172
    174173            if (not ((short is None) or
    175                      (type(short) is StringType and len(short) == 1))):
     174                     (isinstance(short, str) and len(short) == 1))):
    176175                raise DistutilsGetoptError, \
    177176                      ("invalid short option '%s': "
     
    467466    return lines
    468467
    469 # wrap_text ()
    470 
    471 
    472 def translate_longopt (opt):
     468
     469def translate_longopt(opt):
    473470    """Convert a long option name to a valid Python identifier by
    474471    changing "-" to "_".
     
    486483        for opt in options:
    487484            setattr(self, opt, None)
    488 
    489 # class OptionDummy
    490 
    491 
    492 if __name__ == "__main__":
    493     text = """\
    494 Tra-la-la, supercalifragilisticexpialidocious.
    495 How *do* you spell that odd word, anyways?
    496 (Someone ask Mary -- she'll know [or she'll
    497 say, "How should I know?"].)"""
    498 
    499     for w in (10, 20, 30, 40):
    500         print "width: %d" % w
    501         print string.join(wrap_text(text, w), "\n")
    502         print
Note: See TracChangeset for help on using the changeset viewer.