Changeset 391 for python/trunk/Lib/distutils/fancy_getopt.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/distutils/fancy_getopt.py
r2 r391 9 9 """ 10 10 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 13 import sys 14 import string 15 import re 17 16 import getopt 18 from distutils.errors import *17 from distutils.errors import DistutilsGetoptError, DistutilsArgError 19 18 20 19 # Much like command_re in distutils.core, this is close to but not quite … … 120 119 121 120 def _check_alias_dict (self, aliases, what): 122 assert type(aliases) is DictionaryType121 assert isinstance(aliases, dict) 123 122 for (alias, opt) in aliases.items(): 124 123 if alias not in self.option_index: … … 167 166 168 167 # Type- and value-check the option names 169 if type(long) is not StringTypeor len(long) < 2:168 if not isinstance(long, str) or len(long) < 2: 170 169 raise DistutilsGetoptError, \ 171 170 ("invalid long option '%s': " … … 173 172 174 173 if (not ((short is None) or 175 ( type(short) is StringTypeand len(short) == 1))):174 (isinstance(short, str) and len(short) == 1))): 176 175 raise DistutilsGetoptError, \ 177 176 ("invalid short option '%s': " … … 467 466 return lines 468 467 469 # wrap_text () 470 471 472 def translate_longopt (opt): 468 469 def translate_longopt(opt): 473 470 """Convert a long option name to a valid Python identifier by 474 471 changing "-" to "_". … … 486 483 for opt in options: 487 484 setattr(self, opt, None) 488 489 # class OptionDummy490 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'll497 say, "How should I know?"].)"""498 499 for w in (10, 20, 30, 40):500 print "width: %d" % w501 print string.join(wrap_text(text, w), "\n")502 print
Note:
See TracChangeset
for help on using the changeset viewer.